diff --git a/tests/std/include/is_permissive.hpp b/tests/std/include/is_permissive.hpp new file mode 100644 index 00000000000..a007ec5da78 --- /dev/null +++ b/tests/std/include/is_permissive.hpp @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#include + +namespace detail { + constexpr bool permissive() { + return false; + } + + template + struct PermissiveTestBase { + static constexpr bool permissive() { + return true; + } + }; + + template + struct PermissiveTest : PermissiveTestBase { + static constexpr bool test() { + return permissive(); + } + }; +} // namespace detail + +template +_INLINE_VAR constexpr bool is_permissive_v = detail::PermissiveTest::test(); + +_INLINE_VAR constexpr bool is_permissive = is_permissive_v; diff --git a/tests/std/include/range_algorithm_support.hpp b/tests/std/include/range_algorithm_support.hpp index 510d3d295d2..3e69d85de3a 100644 --- a/tests/std/include/range_algorithm_support.hpp +++ b/tests/std/include/range_algorithm_support.hpp @@ -12,6 +12,8 @@ #include #include +#include + #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) namespace ranges = std::ranges; @@ -19,27 +21,6 @@ namespace ranges = std::ranges; template inline constexpr bool always_false = false; -namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace detail -constexpr bool is_permissive = detail::Derived::test(); - template inline constexpr T* nullptr_to = nullptr; diff --git a/tests/std/include/test_mdspan_support.hpp b/tests/std/include/test_mdspan_support.hpp index f2915e98661..de86eee8936 100644 --- a/tests/std/include/test_mdspan_support.hpp +++ b/tests/std/include/test_mdspan_support.hpp @@ -17,6 +17,8 @@ #include #include +#include + enum class IsExplicit : bool { no, yes }; enum class IsNothrow : bool { no, yes }; @@ -173,7 +175,7 @@ constexpr bool check_accessor_policy_requirements() { return true; } -namespace details { +namespace detail { template constexpr void check_members_with_mixed_extents(Fn&& fn) { auto select_extent = [](size_t e) consteval { @@ -221,41 +223,19 @@ namespace details { static_assert(sizeof...(Seq) <= 16, "We don't need more testing."); } } -} // namespace details +} // namespace detail template constexpr void check_members_with_various_extents(Fn&& fn) { - details::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<1>{}); - details::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<2>{}); - details::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<4>{}); - details::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<8>{}); + detail::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<1>{}); + detail::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<2>{}); + detail::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<4>{}); + detail::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<8>{}); if (!std::is_constant_evaluated()) { - details::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<16>{}); + detail::check_members_with_various_extents_impl(std::forward(fn), std::make_index_sequence<16>{}); } } -namespace details { - constexpr bool permissive() { - return false; - } - - template - struct PermissiveTestBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct PermissiveTest : PermissiveTestBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace details - -inline constexpr bool is_permissive = details::PermissiveTest::test(); - template struct MappingProperties { Mapping::index_type req_span_size; @@ -265,7 +245,7 @@ struct MappingProperties { }; template - requires (!details::PermissiveTest::test()) + requires (!is_permissive_v) MappingProperties get_mapping_properties(const Mapping& mapping) { using IndexType = Mapping::index_type; constexpr auto rank = Mapping::extents_type::rank(); @@ -327,7 +307,7 @@ MappingProperties get_mapping_properties(const Mapping& mapping) { } template - requires (details::PermissiveTest::test()) + requires (is_permissive_v) constexpr MappingProperties get_mapping_properties(const Mapping&) { return {}; // we cannot get properties in '/permissive' mode } diff --git a/tests/std/tests/P0645R10_text_formatting_args/test.cpp b/tests/std/tests/P0645R10_text_formatting_args/test.cpp index 1af863a77a2..2c02e298e3d 100644 --- a/tests/std/tests/P0645R10_text_formatting_args/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_args/test.cpp @@ -12,6 +12,8 @@ #include #include +#include + using namespace std; template @@ -265,27 +267,6 @@ void test_lvalue_only_visitation() { visit_format_arg(lvalue_only_visitor{}, basic_format_arg{}); } -namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace detail -constexpr bool is_permissive = detail::Derived::test(); - template concept CanMakeFormatArgs = requires(Args&&... args) { make_format_args(static_cast(args)...); }; diff --git a/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.compile.pass.cpp b/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.compile.pass.cpp index fdef67d884c..14dcb1a4479 100644 --- a/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.compile.pass.cpp +++ b/tests/std/tests/P0896R4_ranges_algorithm_machinery/test.compile.pass.cpp @@ -11,33 +11,14 @@ #include #include +#include + #pragma warning(disable : 4793) // function compiled as native: non-clrcall vcall thunks must be compiled as native #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) namespace ranges = std::ranges; -namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace detail -constexpr bool is_permissive = detail::Derived::test(); - template struct borrowed { // borrowed is a borrowed_range; borrowed is not int* begin() const; diff --git a/tests/std/tests/P0898R3_concepts/test.cpp b/tests/std/tests/P0898R3_concepts/test.cpp index f8219c482bd..7a1f6a4ab60 100644 --- a/tests/std/tests/P0898R3_concepts/test.cpp +++ b/tests/std/tests/P0898R3_concepts/test.cpp @@ -22,6 +22,8 @@ #include #include +#include + #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) template @@ -32,27 +34,6 @@ constexpr bool is_trait> = true; template constexpr bool always_false = false; -namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace detail -constexpr bool is_permissive = detail::Derived::test(); - struct IncompleteClass; union IncompleteUnion; diff --git a/tests/std/tests/P2136R3_invoke_r/test.cpp b/tests/std/tests/P2136R3_invoke_r/test.cpp index 18249daed0a..5f3522b280b 100644 --- a/tests/std/tests/P2136R3_invoke_r/test.cpp +++ b/tests/std/tests/P2136R3_invoke_r/test.cpp @@ -6,32 +6,12 @@ #include #include +#include + #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) using namespace std; -// TRANSITION, DevCom-1457457 -namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; -} // namespace detail -constexpr bool is_permissive = detail::Derived::test(); - constexpr int square(int n) { return n * n; } diff --git a/tests/std/tests/VSO_0000000_type_traits/test.cpp b/tests/std/tests/VSO_0000000_type_traits/test.cpp index 5791b4c618b..c42fb0372fb 100644 --- a/tests/std/tests/VSO_0000000_type_traits/test.cpp +++ b/tests/std/tests/VSO_0000000_type_traits/test.cpp @@ -9,6 +9,8 @@ #include #include +#include + using namespace std; #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) @@ -1268,27 +1270,6 @@ namespace { template constexpr bool is_trait> = true; - namespace detail { - constexpr bool permissive() { - return false; - } - - template - struct DependentBase { - static constexpr bool permissive() { - return true; - } - }; - - template - struct Derived : DependentBase { - static constexpr bool test() { - return permissive(); - } - }; - } // namespace detail - constexpr bool is_permissive = detail::Derived::test(); - struct move_only { move_only() = default; move_only(move_only&&) = default;