diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp index de5f5d5..4ed4ac5 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED #define TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp index 9877ac4..eab9789 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_BOOLEAN_HPP_INCLUDED #define TYPE_SAFE_BOOLEAN_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp index 9eb36eb..3472caa 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED #define TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp index 0e0d984..149d88b 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED #define TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp index 1e209a6..cdb4186 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_CONFIG_HPP_INCLUDED #define TYPE_SAFE_CONFIG_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #ifndef TYPE_SAFE_ENABLE_ASSERTIONS /// Controls whether internal assertions are enabled. diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp index 8e0dd19..d01f36c 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED #define TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp index af1eb3d..5cf97ba 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED #define TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include @@ -166,8 +170,7 @@ class deferred_construction return static_cast(&storage_); } - using storage_t = typename std::aligned_storage::type; - storage_t storage_; + alignas(T) unsigned char storage_[sizeof(T)]; bool initialized_; }; diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp index 6f7cf72..981b50b 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp @@ -5,7 +5,12 @@ #ifndef TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +# include +#endif namespace type_safe { @@ -30,18 +35,25 @@ namespace detail return max(t, max(ts...)); } - // std::aligned_union not available on all compilers template - struct aligned_union + class aligned_union { + public: static constexpr auto size_value = detail::max(sizeof(Types)...); static constexpr auto alignment_value = detail::max(alignof(Types)...); - using type = typename std::aligned_storage::type; + void* get() noexcept + { + return &storage_; + } + const void* get() const noexcept + { + return &storage_; + } + + private: + alignas(alignment_value) unsigned char storage_[size_value]; }; - - template - using aligned_union_t = typename aligned_union::type; } // namespace detail } // namespace type_safe diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp index 8df223b..80ff47f 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp index 2d2897d..b53feb8 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp index 1a52a51..996c46e 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED #define TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp index fede736..b49574c 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED #define TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp index a19ca1f..af03811 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED #define TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp index 9aaaa39..2211958 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DOWNCAST_HPP_INCLUDED #define TYPE_SAFE_DOWNCAST_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp index 500ba7d..0d4ce70 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_FLAG_SET_HPP_INCLUDED #define TYPE_SAFE_FLAG_SET_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp index e813ad0..8a613a2 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED #define TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp index e6e5613..eb3c0e3 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_INDEX_HPP_INCLUDED #define TYPE_SAFE_INDEX_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp index d8674d6..45b3998 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_INTEGER_HPP_INCLUDED #define TYPE_SAFE_INTEGER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include @@ -52,14 +56,6 @@ namespace detail || is_safe_integer_conversion::value> {}; - template - using enable_safe_integer_comparison = - typename std::enable_if::value>::type; - - template - using fallback_safe_integer_comparison = - typename std::enable_if::value>::type; - template struct is_safe_integer_operation : std::integral_constant::value && detail::is_integer::value @@ -269,7 +265,6 @@ class integer { value_ = Policy::template do_subtraction(value_, static_cast(other)); return *this; - return *this; } TYPE_SAFE_DETAIL_MAKE_OP(-=) @@ -455,112 +450,179 @@ TYPE_SAFE_FORCE_INLINE constexpr integer abs( } //=== comparison ===// +/// \exclude +namespace detail +{ + // A signed, B unsigned + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_unsafe_impl(const integer& a, + const integer& b, + std::true_type, + std::false_type) noexcept + { + using UA = typename make_unsigned::type; + return static_cast(a) < 0 ? false : UA(static_cast(a)) == static_cast(b); + } + + // A unsigned, B signed + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_unsafe_impl(const integer& a, + const integer& b, + std::false_type, + std::true_type) noexcept + { + using UB = typename make_unsigned::type; + return static_cast(b) < 0 ? false : UB(static_cast(b)) == static_cast(a); + } + + // A and B same signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_impl(const integer& a, + const integer& b, + std::true_type) noexcept + { + return static_cast(a) == static_cast(b); + } + + // A and B different signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_impl(const integer& a, + const integer& b, + std::false_type) noexcept + { + return cmp_equal_unsafe_impl(a, b, std::is_signed(), std::is_signed()); + } + + // A signed, B unsigned + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_unsafe_impl(const integer& a, + const integer& b, + std::true_type, + std::false_type) noexcept + { + using UA = typename make_unsigned::type; + return static_cast(a) < 0 ? true : UA(static_cast(a)) < static_cast(b); + } + + // A unsigned, B signed + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_unsafe_impl(const integer& a, + const integer& b, + std::false_type, + std::true_type) noexcept + { + using UB = typename make_unsigned::type; + return static_cast(b) < 0 ? false : static_cast(a) < UB(static_cast(b)); + } + + // A and B same signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_impl(const integer& a, + const integer& b, + std::true_type) noexcept + { + return static_cast(a) < static_cast(b); + } + + // A and B different signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_impl(const integer& a, + const integer& b, + std::false_type) noexcept + { + return cmp_less_unsafe_impl(a, b, std::is_signed(), std::is_signed()); + } + +} // namespace detail + /// \exclude #define TYPE_SAFE_DETAIL_MAKE_OP(Op) \ /** \group int_comp \ - * \param 3 \ + * \param 2 \ * \exclude */ \ - template > \ - TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const A& a, const integer& b) \ + template \ + TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const A& a, \ + const integer& b) noexcept \ { \ return integer(a) Op b; \ } \ /** \group int_comp \ - * \param 3 \ + * \param 2 \ * \exclude */ \ - template > \ - TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const integer& a, const B& b) \ + template \ + TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const integer& a, \ + const B& b) noexcept \ { \ return a Op integer(b); \ - } \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(integer, integer) = delete; \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(A, integer) = delete; \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(integer, B) = delete; + } /// \returns The result of the comparison of the stored integer value in the [ts::integer](). /// \notes These functions do not participate in overload resolution /// unless `A` and `B` are both integer types. /// \group int_comp Comparison operators /// \module types -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator==(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) == static_cast(b); + return detail::cmp_equal_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(==) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator!=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) != static_cast(b); + return !detail::cmp_equal_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(!=) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator<(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) < static_cast(b); + return detail::cmp_less_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(<) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator<=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) <= static_cast(b); + return !detail::cmp_less_impl(b, a, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(<=) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator>(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) > static_cast(b); + return detail::cmp_less_impl(b, a, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(>) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator>=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) >= static_cast(b); + return !detail::cmp_less_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(>=) diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp index 99b22fd..47187b1 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp @@ -13,12 +13,22 @@ namespace type_safe /// \exclude namespace detail { + template + struct get_target_underlying_integer + { + using type = T; + }; + template + struct get_target_underlying_integer> + { + using type = T; + }; + template struct get_target_integer { using type = integer; }; - template struct get_target_integer, Policy> { @@ -30,7 +40,6 @@ namespace detail { using type = floating_point; }; - template struct get_target_floating_point> { @@ -71,10 +80,11 @@ template ::value>::type> TYPE_SAFE_FORCE_INLINE constexpr Target narrow_cast(const Source& source) noexcept { - return detail::is_narrowing(source) + using underlying = typename detail::get_target_underlying_integer::type; + return detail::is_narrowing(source) ? DEBUG_UNREACHABLE(detail::precondition_error_handler{}, "conversion would truncate value") - : static_cast(source); + : static_cast(static_cast(source)); } /// \returns A [ts::integer]() with the same value as `source` but of a different type. diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp index dd746ec..014a63d 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_OPTIONAL_HPP_INCLUDED #define TYPE_SAFE_OPTIONAL_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include @@ -251,7 +255,7 @@ class basic_optional : detail::optional_storage, template ::type, basic_optional>::value>::type> basic_optional(T&& value, - decltype(std::declval().create_value(std::forward(value)), 0) = 0) + decltype(std::declval().create_value(std::declval()), 0) = 0) { get_storage().create_value(std::forward(value)); } @@ -268,7 +272,7 @@ class basic_optional : detail::optional_storage, = 0> explicit basic_optional( T&& value, - decltype(std::declval().create_value_explicit(std::forward(value)), 0) = 0) + decltype(std::declval().create_value_explicit(std::declval()), 0) = 0) { get_storage().create_value_explicit(std::forward(value)); } @@ -942,8 +946,7 @@ class direct_optional_storage return static_cast(&storage_); } - using storage_t = typename std::aligned_storage::type; - storage_t storage_; + alignas(value_type) unsigned char storage_[sizeof(value_type)]; bool empty_; }; diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp index b3a2e47..278fd23 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_OUTPUT_PARAMETER_HPP_INCLUDED #define TYPE_SAFE_OUTPUT_PARAMETER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp index 2213261..cd6b2dc 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_REFERENCE_HPP_INCLUDED #define TYPE_SAFE_REFERENCE_HPP_INCLUDED -#include -#include -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +# include +# include +#endif #include #include @@ -125,8 +129,8 @@ class object_ref std::forward(args)...)), XValue> { - using result = decltype( - detail::map_invoke(std::forward(f), get(), std::forward(args)...)); + using result = decltype(detail::map_invoke(std::forward(f), get(), + std::forward(args)...)); return detail::rebind_object_ref( detail::map_invoke(std::forward(f), get(), std::forward(args)...)); } @@ -596,7 +600,7 @@ class function_ref Functor, Return, Args...>> explicit function_ref(Functor& f) : cb_(&invoke_functor) { - ::new (get_memory()) void*(&f); + ::new (storage_.get()) void*(&f); } /// Converting copy constructor. @@ -635,7 +639,7 @@ class function_ref /// \effects Invokes the stored function with the specified arguments and returns the result. Return operator()(Args... args) const { - return cb_(get_memory(), static_cast(args)...); + return cb_(storage_.get(), static_cast(args)...); } private: @@ -664,22 +668,12 @@ class function_ref DEBUG_ASSERT(fptr, detail::precondition_error_handler{}, "function pointer must not be null"); - ::new (get_memory()) stored_pointer_type(reinterpret_cast(fptr)); + ::new (storage_.get()) stored_pointer_type(reinterpret_cast(fptr)); cb_ = &invoke_function_pointer; } - void* get_memory() noexcept - { - return &storage_; - } - - const void* get_memory() const noexcept - { - return &storage_; - } - - using storage = detail::aligned_union_t; + using storage = detail::aligned_union; using callback = Return (*)(const void*, Args...); storage storage_; diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp index f479c59..939d322 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp @@ -5,14 +5,24 @@ #ifndef TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED #define TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include +#ifdef _MSC_VER +# define TYPE_SAFE_MSC_EMPTY_BASES __declspec(empty_bases) +#else +# define TYPE_SAFE_MSC_EMPTY_BASES +#endif + namespace type_safe { /// A strong typedef emulation. @@ -91,7 +101,6 @@ class strong_typedef swap(static_cast(a), static_cast(b)); } -private: T value_; }; @@ -100,6 +109,14 @@ namespace detail { template T underlying_type(strong_typedef); + + template + struct make_void + { + typedef void type; + }; + template + using void_t = typename make_void::type; } // namespace detail /// The underlying type of the [ts::strong_typedef](). @@ -108,6 +125,19 @@ template using underlying_type = decltype(detail::underlying_type(std::declval::type>())); + +/// \group is_strong_typedef +/// Whether a type `T` is a [ts::strong_type]() +template > +struct TYPE_SAFE_MSC_EMPTY_BASES is_strong_typedef : std::false_type +{}; + +/// \group is_strong_typedef +template +struct is_strong_typedef()))>> + : std::true_type +{}; + /// Accesses the underlying value. /// \returns A reference to the underlying value. /// \group strong_typedef_get @@ -190,24 +220,6 @@ namespace strong_typedef_op return static_cast(t); } - template - struct make_void - { - typedef void type; - }; - template - using void_t = typename make_void::type; - - template > - struct is_strong_typedef : std::false_type - {}; - - template - struct is_strong_typedef< - T, void_t()))>> - : std::true_type - {}; - template ::value>::type> constexpr auto forward_or_underlying(StrongTypedef&& type) noexcept @@ -548,24 +560,24 @@ namespace strong_typedef_op } template - struct integer_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division, - modulo, - increment, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES integer_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division, + modulo, + increment, + decrement {}; template - struct floating_point_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division + struct TYPE_SAFE_MSC_EMPTY_BASES floating_point_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division {}; template @@ -590,10 +602,10 @@ namespace strong_typedef_op TYPE_SAFE_DETAIL_MAKE_STRONG_TYPEDEF_OP(bitwise_and, &) template - struct bitmask : complement, - bitwise_or, - bitwise_xor, - bitwise_and + struct TYPE_SAFE_MSC_EMPTY_BASES bitmask : complement, + bitwise_or, + bitwise_xor, + bitwise_and {}; template @@ -656,7 +668,8 @@ namespace strong_typedef_op }; template - struct iterator : dereference, increment + struct TYPE_SAFE_MSC_EMPTY_BASES iterator : dereference, + increment { using iterator_category = Category; using value_type = typename std::remove_cv::type; @@ -666,31 +679,31 @@ namespace strong_typedef_op }; template - struct input_iterator : iterator, - equality_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES input_iterator : iterator, + equality_comparison {}; template - struct output_iterator : iterator + struct TYPE_SAFE_MSC_EMPTY_BASES output_iterator : iterator {}; template - struct forward_iterator : input_iterator + struct TYPE_SAFE_MSC_EMPTY_BASES forward_iterator : input_iterator { using iterator_category = std::forward_iterator_tag; }; template - struct bidirectional_iterator : forward_iterator, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES bidirectional_iterator : forward_iterator, + decrement { using iterator_category = std::bidirectional_iterator_tag; }; template - struct random_access_iterator : bidirectional_iterator, - array_subscript, - relational_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES random_access_iterator : bidirectional_iterator, + array_subscript, + relational_comparison { using iterator_category = std::random_access_iterator_tag; @@ -775,7 +788,7 @@ namespace strong_typedef_op /// Inherit from it in the `std::hash` specialization to make /// it hashable like the underlying type. See example/strong_typedef.cpp. template -struct hashable : std::hash> +struct TYPE_SAFE_MSC_EMPTY_BASES hashable : std::hash> { using underlying_type = type_safe::underlying_type; using underlying_hash = std::hash; @@ -788,4 +801,6 @@ struct hashable : std::hash> }; } // namespace type_safe +#undef TYPE_SAFE_MSC_EMPTY_BASES + #endif // TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp index de6c18e..17b57ca 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_TAGGED_UNION_HPP_INCLUDED #define TYPE_SAFE_TAGGED_UNION_HPP_INCLUDED -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +#endif #include #include @@ -149,7 +153,7 @@ class tagged_union /// \notes Does not destroy the currently stored type. ~tagged_union() noexcept = default; - tagged_union(const tagged_union&) = delete; + tagged_union(const tagged_union&) = delete; tagged_union& operator=(const tagged_union&) = delete; //=== modifiers ===// @@ -167,7 +171,7 @@ class tagged_union static_assert(std::is_constructible::value, "T not constructible from arguments"); - ::new (get_memory()) T(std::forward(args)...); + ::new (storage_.get()) T(std::forward(args)...); cur_type_ = index; } @@ -204,7 +208,7 @@ class tagged_union T& value(union_type type) TYPE_SAFE_LVALUE_REF noexcept { check(type); - return *static_cast(get_memory()); + return *static_cast(storage_.get()); } /// \group value @@ -212,16 +216,16 @@ class tagged_union const T& value(union_type type) const TYPE_SAFE_LVALUE_REF noexcept { check(type); - return *static_cast(get_memory()); + return *static_cast(storage_.get()); } #if TYPE_SAFE_USE_REF_QUALIFIERS /// \group value template - T&& value(union_type type) && noexcept + T&& value(union_type type) && noexcept { check(type); - return std::move(*static_cast(get_memory())); + return std::move(*static_cast(storage_.get())); } /// \group value @@ -229,21 +233,11 @@ class tagged_union const T&& value(union_type type) const&& noexcept { check(type); - return std::move(*static_cast(get_memory())); + return std::move(*static_cast(storage_.get())); } #endif private: - void* get_memory() noexcept - { - return static_cast(&storage_); - } - - const void* get_memory() const noexcept - { - return static_cast(&storage_); - } - template void check(union_type type) const noexcept { @@ -251,7 +245,7 @@ class tagged_union "different type stored in union"); } - using storage_t = detail::aligned_union_t; + using storage_t = detail::aligned_union; storage_t storage_; type_id cur_type_; }; diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp index 05bbe73..1f6087b 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_TYPES_HPP_INCLUDED #define TYPE_SAFE_TYPES_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include @@ -55,23 +59,23 @@ namespace detail inline namespace types { - //=== fixed with integer ===// + //=== fixed width integer ===// /// \module types - using int8_t = TYPE_SAFE_DETAIL_WRAP(integer, int8_t); + using int8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int8_t); /// \module types - using int16_t = TYPE_SAFE_DETAIL_WRAP(integer, int16_t); + using int16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int16_t); /// \module types - using int32_t = TYPE_SAFE_DETAIL_WRAP(integer, int32_t); + using int32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int32_t); /// \module types - using int64_t = TYPE_SAFE_DETAIL_WRAP(integer, int64_t); + using int64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int64_t); /// \module types - using uint8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint8_t); + using uint8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint8_t); /// \module types - using uint16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint16_t); + using uint16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint16_t); /// \module types - using uint32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint32_t); + using uint32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint32_t); /// \module types - using uint64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint64_t); + using uint64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint64_t); inline namespace literals { @@ -133,53 +137,53 @@ inline namespace types } // namespace literals /// \module types - using int_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast8_t); + using int_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast8_t); /// \module types - using int_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast16_t); + using int_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast16_t); /// \module types - using int_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast32_t); + using int_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast32_t); /// \module types - using int_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast64_t); + using int_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast64_t); /// \module types - using uint_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast8_t); + using uint_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast8_t); /// \module types - using uint_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast16_t); + using uint_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast16_t); /// \module types - using uint_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast32_t); + using uint_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast32_t); /// \module types - using uint_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast64_t); + using uint_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast64_t); /// \module types - using int_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least8_t); + using int_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least8_t); /// \module types - using int_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least16_t); + using int_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least16_t); /// \module types - using int_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least32_t); + using int_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least32_t); /// \module types - using int_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least64_t); + using int_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least64_t); /// \module types - using uint_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least8_t); + using uint_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least8_t); /// \module types - using uint_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least16_t); + using uint_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least16_t); /// \module types - using uint_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least32_t); + using uint_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least32_t); /// \module types - using uint_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least64_t); + using uint_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least64_t); /// \module types - using intmax_t = TYPE_SAFE_DETAIL_WRAP(integer, intmax_t); + using intmax_t = TYPE_SAFE_DETAIL_WRAP(integer, std::intmax_t); /// \module types - using uintmax_t = TYPE_SAFE_DETAIL_WRAP(integer, uintmax_t); + using uintmax_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uintmax_t); /// \module types - using intptr_t = TYPE_SAFE_DETAIL_WRAP(integer, intptr_t); + using intptr_t = TYPE_SAFE_DETAIL_WRAP(integer, std::intptr_t); /// \module types - using uintptr_t = TYPE_SAFE_DETAIL_WRAP(integer, uintptr_t); + using uintptr_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uintptr_t); //=== special integer types ===// /// \module types - using ptrdiff_t = TYPE_SAFE_DETAIL_WRAP(integer, ptrdiff_t); + using ptrdiff_t = TYPE_SAFE_DETAIL_WRAP(integer, std::ptrdiff_t); /// \module types - using size_t = TYPE_SAFE_DETAIL_WRAP(integer, size_t); + using size_t = TYPE_SAFE_DETAIL_WRAP(integer, std::size_t); /// \module types using int_t = TYPE_SAFE_DETAIL_WRAP(integer, int); diff --git a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp index ec009ec..7535bc7 100644 --- a/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp +++ b/example/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_VISITOR_HPP_INCLUDED #define TYPE_SAFE_VISITOR_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/example/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp b/example/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp index 9c2f8b9..df79814 100644 --- a/example/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp +++ b/example/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp @@ -1,6 +1,6 @@ #pragma once -// pqrs::cf::run_loop_thread v2.4 +// pqrs::cf::run_loop_thread v2.5 // (C) Copyright Takayama Fumihiko 2018. // Distributed under the Boost Software License, Version 1.0. @@ -82,7 +82,8 @@ class run_loop_thread final { } } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + // The period of time should be as short as possible, as the thread sleeps at least once here. + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp index de5f5d5..4ed4ac5 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/arithmetic_policy.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED #define TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp index 9877ac4..eab9789 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/boolean.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_BOOLEAN_HPP_INCLUDED #define TYPE_SAFE_BOOLEAN_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp index 9eb36eb..3472caa 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/bounded_type.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED #define TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp index 0e0d984..149d88b 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/compact_optional.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED #define TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp index 1e209a6..cdb4186 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/config.hpp @@ -5,8 +5,12 @@ #ifndef TYPE_SAFE_CONFIG_HPP_INCLUDED #define TYPE_SAFE_CONFIG_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include +#endif #ifndef TYPE_SAFE_ENABLE_ASSERTIONS /// Controls whether internal assertions are enabled. diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp index 8e0dd19..d01f36c 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/constrained_type.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED #define TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp index af1eb3d..5cf97ba 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/deferred_construction.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED #define TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include @@ -166,8 +170,7 @@ class deferred_construction return static_cast(&storage_); } - using storage_t = typename std::aligned_storage::type; - storage_t storage_; + alignas(T) unsigned char storage_[sizeof(T)]; bool initialized_; }; diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp index 6f7cf72..981b50b 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/aligned_union.hpp @@ -5,7 +5,12 @@ #ifndef TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +# include +#endif namespace type_safe { @@ -30,18 +35,25 @@ namespace detail return max(t, max(ts...)); } - // std::aligned_union not available on all compilers template - struct aligned_union + class aligned_union { + public: static constexpr auto size_value = detail::max(sizeof(Types)...); static constexpr auto alignment_value = detail::max(alignof(Types)...); - using type = typename std::aligned_storage::type; + void* get() noexcept + { + return &storage_; + } + const void* get() const noexcept + { + return &storage_; + } + + private: + alignas(alignment_value) unsigned char storage_[size_value]; }; - - template - using aligned_union_t = typename aligned_union::type; } // namespace detail } // namespace type_safe diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp index 8df223b..80ff47f 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/all_of.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp index 2d2897d..b53feb8 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/assign_or_construct.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED #define TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp index 1a52a51..996c46e 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/constant_parser.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED #define TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp index fede736..b49574c 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/is_nothrow_swappable.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED #define TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp index a19ca1f..af03811 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/detail/map_invoke.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED #define TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif namespace type_safe { diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp index 9aaaa39..2211958 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/downcast.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_DOWNCAST_HPP_INCLUDED #define TYPE_SAFE_DOWNCAST_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp index 500ba7d..0d4ce70 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/flag_set.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_FLAG_SET_HPP_INCLUDED #define TYPE_SAFE_FLAG_SET_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp index e813ad0..8a613a2 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/floating_point.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED #define TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp index e6e5613..eb3c0e3 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/index.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_INDEX_HPP_INCLUDED #define TYPE_SAFE_INDEX_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp index d8674d6..45b3998 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/integer.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_INTEGER_HPP_INCLUDED #define TYPE_SAFE_INTEGER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include @@ -52,14 +56,6 @@ namespace detail || is_safe_integer_conversion::value> {}; - template - using enable_safe_integer_comparison = - typename std::enable_if::value>::type; - - template - using fallback_safe_integer_comparison = - typename std::enable_if::value>::type; - template struct is_safe_integer_operation : std::integral_constant::value && detail::is_integer::value @@ -269,7 +265,6 @@ class integer { value_ = Policy::template do_subtraction(value_, static_cast(other)); return *this; - return *this; } TYPE_SAFE_DETAIL_MAKE_OP(-=) @@ -455,112 +450,179 @@ TYPE_SAFE_FORCE_INLINE constexpr integer abs( } //=== comparison ===// +/// \exclude +namespace detail +{ + // A signed, B unsigned + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_unsafe_impl(const integer& a, + const integer& b, + std::true_type, + std::false_type) noexcept + { + using UA = typename make_unsigned::type; + return static_cast(a) < 0 ? false : UA(static_cast(a)) == static_cast(b); + } + + // A unsigned, B signed + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_unsafe_impl(const integer& a, + const integer& b, + std::false_type, + std::true_type) noexcept + { + using UB = typename make_unsigned::type; + return static_cast(b) < 0 ? false : UB(static_cast(b)) == static_cast(a); + } + + // A and B same signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_impl(const integer& a, + const integer& b, + std::true_type) noexcept + { + return static_cast(a) == static_cast(b); + } + + // A and B different signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_equal_impl(const integer& a, + const integer& b, + std::false_type) noexcept + { + return cmp_equal_unsafe_impl(a, b, std::is_signed(), std::is_signed()); + } + + // A signed, B unsigned + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_unsafe_impl(const integer& a, + const integer& b, + std::true_type, + std::false_type) noexcept + { + using UA = typename make_unsigned::type; + return static_cast(a) < 0 ? true : UA(static_cast(a)) < static_cast(b); + } + + // A unsigned, B signed + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_unsafe_impl(const integer& a, + const integer& b, + std::false_type, + std::true_type) noexcept + { + using UB = typename make_unsigned::type; + return static_cast(b) < 0 ? false : static_cast(a) < UB(static_cast(b)); + } + + // A and B same signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_impl(const integer& a, + const integer& b, + std::true_type) noexcept + { + return static_cast(a) < static_cast(b); + } + + // A and B different signedness + template + TYPE_SAFE_FORCE_INLINE constexpr bool cmp_less_impl(const integer& a, + const integer& b, + std::false_type) noexcept + { + return cmp_less_unsafe_impl(a, b, std::is_signed(), std::is_signed()); + } + +} // namespace detail + /// \exclude #define TYPE_SAFE_DETAIL_MAKE_OP(Op) \ /** \group int_comp \ - * \param 3 \ + * \param 2 \ * \exclude */ \ - template > \ - TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const A& a, const integer& b) \ + template \ + TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const A& a, \ + const integer& b) noexcept \ { \ return integer(a) Op b; \ } \ /** \group int_comp \ - * \param 3 \ + * \param 2 \ * \exclude */ \ - template > \ - TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const integer& a, const B& b) \ + template \ + TYPE_SAFE_FORCE_INLINE constexpr bool operator Op(const integer& a, \ + const B& b) noexcept \ { \ return a Op integer(b); \ - } \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(integer, integer) = delete; \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(A, integer) = delete; \ - /** \exclude */ \ - template > \ - constexpr bool operator Op(integer, B) = delete; + } /// \returns The result of the comparison of the stored integer value in the [ts::integer](). /// \notes These functions do not participate in overload resolution /// unless `A` and `B` are both integer types. /// \group int_comp Comparison operators /// \module types -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator==(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) == static_cast(b); + return detail::cmp_equal_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(==) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator!=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) != static_cast(b); + return !detail::cmp_equal_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(!=) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator<(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) < static_cast(b); + return detail::cmp_less_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(<) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator<=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) <= static_cast(b); + return !detail::cmp_less_impl(b, a, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(<=) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator>(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) > static_cast(b); + return detail::cmp_less_impl(b, a, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(>) /// \group int_comp Comparison operators -/// \param 3 +/// \param 2 /// \exclude -template > +template TYPE_SAFE_FORCE_INLINE constexpr bool operator>=(const integer& a, - const integer& b) + const integer& b) noexcept { - return static_cast(a) >= static_cast(b); + return !detail::cmp_less_impl(a, b, detail::is_safe_integer_comparison()); } TYPE_SAFE_DETAIL_MAKE_OP(>=) diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp index 99b22fd..47187b1 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/narrow_cast.hpp @@ -13,12 +13,22 @@ namespace type_safe /// \exclude namespace detail { + template + struct get_target_underlying_integer + { + using type = T; + }; + template + struct get_target_underlying_integer> + { + using type = T; + }; + template struct get_target_integer { using type = integer; }; - template struct get_target_integer, Policy> { @@ -30,7 +40,6 @@ namespace detail { using type = floating_point; }; - template struct get_target_floating_point> { @@ -71,10 +80,11 @@ template ::value>::type> TYPE_SAFE_FORCE_INLINE constexpr Target narrow_cast(const Source& source) noexcept { - return detail::is_narrowing(source) + using underlying = typename detail::get_target_underlying_integer::type; + return detail::is_narrowing(source) ? DEBUG_UNREACHABLE(detail::precondition_error_handler{}, "conversion would truncate value") - : static_cast(source); + : static_cast(static_cast(source)); } /// \returns A [ts::integer]() with the same value as `source` but of a different type. diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp index dd746ec..014a63d 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/optional.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_OPTIONAL_HPP_INCLUDED #define TYPE_SAFE_OPTIONAL_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include +#endif #include #include @@ -251,7 +255,7 @@ class basic_optional : detail::optional_storage, template ::type, basic_optional>::value>::type> basic_optional(T&& value, - decltype(std::declval().create_value(std::forward(value)), 0) = 0) + decltype(std::declval().create_value(std::declval()), 0) = 0) { get_storage().create_value(std::forward(value)); } @@ -268,7 +272,7 @@ class basic_optional : detail::optional_storage, = 0> explicit basic_optional( T&& value, - decltype(std::declval().create_value_explicit(std::forward(value)), 0) = 0) + decltype(std::declval().create_value_explicit(std::declval()), 0) = 0) { get_storage().create_value_explicit(std::forward(value)); } @@ -942,8 +946,7 @@ class direct_optional_storage return static_cast(&storage_); } - using storage_t = typename std::aligned_storage::type; - storage_t storage_; + alignas(value_type) unsigned char storage_[sizeof(value_type)]; bool empty_; }; diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp index b3a2e47..278fd23 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/output_parameter.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_OUTPUT_PARAMETER_HPP_INCLUDED #define TYPE_SAFE_OUTPUT_PARAMETER_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp index 2213261..cd6b2dc 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/reference.hpp @@ -5,9 +5,13 @@ #ifndef TYPE_SAFE_REFERENCE_HPP_INCLUDED #define TYPE_SAFE_REFERENCE_HPP_INCLUDED -#include -#include -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +# include +# include +#endif #include #include @@ -125,8 +129,8 @@ class object_ref std::forward(args)...)), XValue> { - using result = decltype( - detail::map_invoke(std::forward(f), get(), std::forward(args)...)); + using result = decltype(detail::map_invoke(std::forward(f), get(), + std::forward(args)...)); return detail::rebind_object_ref( detail::map_invoke(std::forward(f), get(), std::forward(args)...)); } @@ -596,7 +600,7 @@ class function_ref Functor, Return, Args...>> explicit function_ref(Functor& f) : cb_(&invoke_functor) { - ::new (get_memory()) void*(&f); + ::new (storage_.get()) void*(&f); } /// Converting copy constructor. @@ -635,7 +639,7 @@ class function_ref /// \effects Invokes the stored function with the specified arguments and returns the result. Return operator()(Args... args) const { - return cb_(get_memory(), static_cast(args)...); + return cb_(storage_.get(), static_cast(args)...); } private: @@ -664,22 +668,12 @@ class function_ref DEBUG_ASSERT(fptr, detail::precondition_error_handler{}, "function pointer must not be null"); - ::new (get_memory()) stored_pointer_type(reinterpret_cast(fptr)); + ::new (storage_.get()) stored_pointer_type(reinterpret_cast(fptr)); cb_ = &invoke_function_pointer; } - void* get_memory() noexcept - { - return &storage_; - } - - const void* get_memory() const noexcept - { - return &storage_; - } - - using storage = detail::aligned_union_t; + using storage = detail::aligned_union; using callback = Return (*)(const void*, Args...); storage storage_; diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp index f479c59..939d322 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/strong_typedef.hpp @@ -5,14 +5,24 @@ #ifndef TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED #define TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include +#ifdef _MSC_VER +# define TYPE_SAFE_MSC_EMPTY_BASES __declspec(empty_bases) +#else +# define TYPE_SAFE_MSC_EMPTY_BASES +#endif + namespace type_safe { /// A strong typedef emulation. @@ -91,7 +101,6 @@ class strong_typedef swap(static_cast(a), static_cast(b)); } -private: T value_; }; @@ -100,6 +109,14 @@ namespace detail { template T underlying_type(strong_typedef); + + template + struct make_void + { + typedef void type; + }; + template + using void_t = typename make_void::type; } // namespace detail /// The underlying type of the [ts::strong_typedef](). @@ -108,6 +125,19 @@ template using underlying_type = decltype(detail::underlying_type(std::declval::type>())); + +/// \group is_strong_typedef +/// Whether a type `T` is a [ts::strong_type]() +template > +struct TYPE_SAFE_MSC_EMPTY_BASES is_strong_typedef : std::false_type +{}; + +/// \group is_strong_typedef +template +struct is_strong_typedef()))>> + : std::true_type +{}; + /// Accesses the underlying value. /// \returns A reference to the underlying value. /// \group strong_typedef_get @@ -190,24 +220,6 @@ namespace strong_typedef_op return static_cast(t); } - template - struct make_void - { - typedef void type; - }; - template - using void_t = typename make_void::type; - - template > - struct is_strong_typedef : std::false_type - {}; - - template - struct is_strong_typedef< - T, void_t()))>> - : std::true_type - {}; - template ::value>::type> constexpr auto forward_or_underlying(StrongTypedef&& type) noexcept @@ -548,24 +560,24 @@ namespace strong_typedef_op } template - struct integer_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division, - modulo, - increment, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES integer_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division, + modulo, + increment, + decrement {}; template - struct floating_point_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division + struct TYPE_SAFE_MSC_EMPTY_BASES floating_point_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division {}; template @@ -590,10 +602,10 @@ namespace strong_typedef_op TYPE_SAFE_DETAIL_MAKE_STRONG_TYPEDEF_OP(bitwise_and, &) template - struct bitmask : complement, - bitwise_or, - bitwise_xor, - bitwise_and + struct TYPE_SAFE_MSC_EMPTY_BASES bitmask : complement, + bitwise_or, + bitwise_xor, + bitwise_and {}; template @@ -656,7 +668,8 @@ namespace strong_typedef_op }; template - struct iterator : dereference, increment + struct TYPE_SAFE_MSC_EMPTY_BASES iterator : dereference, + increment { using iterator_category = Category; using value_type = typename std::remove_cv::type; @@ -666,31 +679,31 @@ namespace strong_typedef_op }; template - struct input_iterator : iterator, - equality_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES input_iterator : iterator, + equality_comparison {}; template - struct output_iterator : iterator + struct TYPE_SAFE_MSC_EMPTY_BASES output_iterator : iterator {}; template - struct forward_iterator : input_iterator + struct TYPE_SAFE_MSC_EMPTY_BASES forward_iterator : input_iterator { using iterator_category = std::forward_iterator_tag; }; template - struct bidirectional_iterator : forward_iterator, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES bidirectional_iterator : forward_iterator, + decrement { using iterator_category = std::bidirectional_iterator_tag; }; template - struct random_access_iterator : bidirectional_iterator, - array_subscript, - relational_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES random_access_iterator : bidirectional_iterator, + array_subscript, + relational_comparison { using iterator_category = std::random_access_iterator_tag; @@ -775,7 +788,7 @@ namespace strong_typedef_op /// Inherit from it in the `std::hash` specialization to make /// it hashable like the underlying type. See example/strong_typedef.cpp. template -struct hashable : std::hash> +struct TYPE_SAFE_MSC_EMPTY_BASES hashable : std::hash> { using underlying_type = type_safe::underlying_type; using underlying_hash = std::hash; @@ -788,4 +801,6 @@ struct hashable : std::hash> }; } // namespace type_safe +#undef TYPE_SAFE_MSC_EMPTY_BASES + #endif // TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp index de6c18e..17b57ca 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/tagged_union.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_TAGGED_UNION_HPP_INCLUDED #define TYPE_SAFE_TAGGED_UNION_HPP_INCLUDED -#include +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else +# include +#endif #include #include @@ -149,7 +153,7 @@ class tagged_union /// \notes Does not destroy the currently stored type. ~tagged_union() noexcept = default; - tagged_union(const tagged_union&) = delete; + tagged_union(const tagged_union&) = delete; tagged_union& operator=(const tagged_union&) = delete; //=== modifiers ===// @@ -167,7 +171,7 @@ class tagged_union static_assert(std::is_constructible::value, "T not constructible from arguments"); - ::new (get_memory()) T(std::forward(args)...); + ::new (storage_.get()) T(std::forward(args)...); cur_type_ = index; } @@ -204,7 +208,7 @@ class tagged_union T& value(union_type type) TYPE_SAFE_LVALUE_REF noexcept { check(type); - return *static_cast(get_memory()); + return *static_cast(storage_.get()); } /// \group value @@ -212,16 +216,16 @@ class tagged_union const T& value(union_type type) const TYPE_SAFE_LVALUE_REF noexcept { check(type); - return *static_cast(get_memory()); + return *static_cast(storage_.get()); } #if TYPE_SAFE_USE_REF_QUALIFIERS /// \group value template - T&& value(union_type type) && noexcept + T&& value(union_type type) && noexcept { check(type); - return std::move(*static_cast(get_memory())); + return std::move(*static_cast(storage_.get())); } /// \group value @@ -229,21 +233,11 @@ class tagged_union const T&& value(union_type type) const&& noexcept { check(type); - return std::move(*static_cast(get_memory())); + return std::move(*static_cast(storage_.get())); } #endif private: - void* get_memory() noexcept - { - return static_cast(&storage_); - } - - const void* get_memory() const noexcept - { - return static_cast(&storage_); - } - template void check(union_type type) const noexcept { @@ -251,7 +245,7 @@ class tagged_union "different type stored in union"); } - using storage_t = detail::aligned_union_t; + using storage_t = detail::aligned_union; storage_t storage_; type_id cur_type_; }; diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp index 05bbe73..1f6087b 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/types.hpp @@ -5,10 +5,14 @@ #ifndef TYPE_SAFE_TYPES_HPP_INCLUDED #define TYPE_SAFE_TYPES_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include #include #include #include +#endif #include #include @@ -55,23 +59,23 @@ namespace detail inline namespace types { - //=== fixed with integer ===// + //=== fixed width integer ===// /// \module types - using int8_t = TYPE_SAFE_DETAIL_WRAP(integer, int8_t); + using int8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int8_t); /// \module types - using int16_t = TYPE_SAFE_DETAIL_WRAP(integer, int16_t); + using int16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int16_t); /// \module types - using int32_t = TYPE_SAFE_DETAIL_WRAP(integer, int32_t); + using int32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int32_t); /// \module types - using int64_t = TYPE_SAFE_DETAIL_WRAP(integer, int64_t); + using int64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int64_t); /// \module types - using uint8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint8_t); + using uint8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint8_t); /// \module types - using uint16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint16_t); + using uint16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint16_t); /// \module types - using uint32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint32_t); + using uint32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint32_t); /// \module types - using uint64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint64_t); + using uint64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint64_t); inline namespace literals { @@ -133,53 +137,53 @@ inline namespace types } // namespace literals /// \module types - using int_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast8_t); + using int_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast8_t); /// \module types - using int_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast16_t); + using int_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast16_t); /// \module types - using int_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast32_t); + using int_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast32_t); /// \module types - using int_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_fast64_t); + using int_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_fast64_t); /// \module types - using uint_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast8_t); + using uint_fast8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast8_t); /// \module types - using uint_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast16_t); + using uint_fast16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast16_t); /// \module types - using uint_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast32_t); + using uint_fast32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast32_t); /// \module types - using uint_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_fast64_t); + using uint_fast64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_fast64_t); /// \module types - using int_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least8_t); + using int_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least8_t); /// \module types - using int_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least16_t); + using int_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least16_t); /// \module types - using int_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least32_t); + using int_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least32_t); /// \module types - using int_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, int_least64_t); + using int_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::int_least64_t); /// \module types - using uint_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least8_t); + using uint_least8_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least8_t); /// \module types - using uint_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least16_t); + using uint_least16_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least16_t); /// \module types - using uint_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least32_t); + using uint_least32_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least32_t); /// \module types - using uint_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, uint_least64_t); + using uint_least64_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uint_least64_t); /// \module types - using intmax_t = TYPE_SAFE_DETAIL_WRAP(integer, intmax_t); + using intmax_t = TYPE_SAFE_DETAIL_WRAP(integer, std::intmax_t); /// \module types - using uintmax_t = TYPE_SAFE_DETAIL_WRAP(integer, uintmax_t); + using uintmax_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uintmax_t); /// \module types - using intptr_t = TYPE_SAFE_DETAIL_WRAP(integer, intptr_t); + using intptr_t = TYPE_SAFE_DETAIL_WRAP(integer, std::intptr_t); /// \module types - using uintptr_t = TYPE_SAFE_DETAIL_WRAP(integer, uintptr_t); + using uintptr_t = TYPE_SAFE_DETAIL_WRAP(integer, std::uintptr_t); //=== special integer types ===// /// \module types - using ptrdiff_t = TYPE_SAFE_DETAIL_WRAP(integer, ptrdiff_t); + using ptrdiff_t = TYPE_SAFE_DETAIL_WRAP(integer, std::ptrdiff_t); /// \module types - using size_t = TYPE_SAFE_DETAIL_WRAP(integer, size_t); + using size_t = TYPE_SAFE_DETAIL_WRAP(integer, std::size_t); /// \module types using int_t = TYPE_SAFE_DETAIL_WRAP(integer, int); diff --git a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp index ec009ec..7535bc7 100644 --- a/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp +++ b/tests/vendor/cget/pkg/foonathan__type_safe/install/include/type_safe/visitor.hpp @@ -5,7 +5,11 @@ #ifndef TYPE_SAFE_VISITOR_HPP_INCLUDED #define TYPE_SAFE_VISITOR_HPP_INCLUDED +#if defined(TYPE_SAFE_IMPORT_STD_MODULE) +import std; +#else #include +#endif #include #include diff --git a/tests/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp b/tests/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp index 9c2f8b9..df79814 100644 --- a/tests/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp +++ b/tests/vendor/cget/pkg/pqrs-org__cpp-cf-run_loop_thread/install/include/pqrs/cf/run_loop_thread.hpp @@ -1,6 +1,6 @@ #pragma once -// pqrs::cf::run_loop_thread v2.4 +// pqrs::cf::run_loop_thread v2.5 // (C) Copyright Takayama Fumihiko 2018. // Distributed under the Boost Software License, Version 1.0. @@ -82,7 +82,8 @@ class run_loop_thread final { } } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + // The period of time should be as short as possible, as the thread sleeps at least once here. + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } }