Skip to content

Commit

Permalink
Drop inline/_INLINE_VAR from templated constexpr variables
Browse files Browse the repository at this point in the history
  • Loading branch information
frederick-vs-ja committed Mar 31, 2024
1 parent be81252 commit d7e4c4c
Show file tree
Hide file tree
Showing 55 changed files with 536 additions and 558 deletions.
4 changes: 2 additions & 2 deletions stl/inc/__msvc_bit_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ _INLINE_VAR constexpr int _Stl_isa_available_sse42 = 2; // equal to __ISA_AVAILA
_INLINE_VAR constexpr int _Stl_isa_available_avx2 = 5; // equal to __ISA_AVAILABLE_AVX2

template <class _UInt>
_INLINE_VAR constexpr int _Unsigned_integer_digits = sizeof(_UInt) * CHAR_BIT;
constexpr int _Unsigned_integer_digits = sizeof(_UInt) * CHAR_BIT;

// Implementation of countl_zero without using specialized CPU instructions.
// Used at compile time and when said instructions are not supported.
Expand Down Expand Up @@ -356,7 +356,7 @@ _NODISCARD inline int _Arm64_popcount(const unsigned long long _Val) noexcept {
#endif // _HAS_NEON_INTRINSICS

template <class _Ty>
_INLINE_VAR constexpr bool _Is_standard_unsigned_integer =
constexpr bool _Is_standard_unsigned_integer =
_Is_any_of_v<remove_cv_t<_Ty>, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>;

template <class _Ty, enable_if_t<_Is_standard_unsigned_integer<_Ty>, int> = 0>
Expand Down
15 changes: 7 additions & 8 deletions stl/inc/__msvc_chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace chrono {
struct treat_as_floating_point : is_floating_point<_Rep> {}; // tests for floating-point type

_EXPORT_STD template <class _Rep>
_INLINE_VAR constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;

_EXPORT_STD template <class _Rep>
struct duration_values { // gets arithmetic properties of a type
Expand All @@ -53,25 +53,25 @@ namespace chrono {

#if _HAS_CXX20
template <class _Clock, class = void>
inline constexpr bool _Is_clock_v = false;
constexpr bool _Is_clock_v = false;

template <class _Clock>
inline constexpr bool
constexpr bool
_Is_clock_v<_Clock, void_t<typename _Clock::rep, typename _Clock::period, typename _Clock::duration,
typename _Clock::time_point, decltype(_Clock::is_steady), decltype(_Clock::now())>> =
true; // TRANSITION, GH-602

_EXPORT_STD template <class _Clock>
struct is_clock : bool_constant<_Is_clock_v<_Clock>> {};
_EXPORT_STD template <class _Clock>
inline constexpr bool is_clock_v = _Is_clock_v<_Clock>;
constexpr bool is_clock_v = _Is_clock_v<_Clock>;
#endif // _HAS_CXX20

_EXPORT_STD template <class _Rep, class _Period = ratio<1>>
class duration;

template <class _Ty>
_INLINE_VAR constexpr bool _Is_duration_v = _Is_specialization_v<_Ty, duration>;
constexpr bool _Is_duration_v = _Is_specialization_v<_Ty, duration>;

_EXPORT_STD template <class _To, class _Rep, class _Period, enable_if_t<_Is_duration_v<_To>, int> = 0>
constexpr _To duration_cast(const duration<_Rep, _Period>&) noexcept(
Expand Down Expand Up @@ -252,11 +252,10 @@ namespace chrono {
} // namespace chrono

template <class _Rep, class _Period>
_INLINE_VAR constexpr bool _Is_trivially_swappable_v<chrono::duration<_Rep, _Period>> = _Is_trivially_swappable_v<_Rep>;
constexpr bool _Is_trivially_swappable_v<chrono::duration<_Rep, _Period>> = _Is_trivially_swappable_v<_Rep>;

template <class _Clock, class _Duration>
_INLINE_VAR constexpr bool _Is_trivially_swappable_v<chrono::time_point<_Clock, _Duration>> =
_Is_trivially_swappable_v<_Duration>;
constexpr bool _Is_trivially_swappable_v<chrono::time_point<_Clock, _Duration>> = _Is_trivially_swappable_v<_Duration>;

_NODISCARD constexpr intmax_t _Lcm(const intmax_t _Ax, const intmax_t _Bx) noexcept {
return (_Ax / _Gcd(_Ax, _Bx)) * _Bx;
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/__msvc_filebuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace experimental {

// clang-format off
template <class _Ty>
_INLINE_VAR constexpr bool _Is_any_path = _Is_any_of_v<_Ty
constexpr bool _Is_any_path = _Is_any_of_v<_Ty
#if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
, experimental::filesystem::path
#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/__msvc_iter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _EXPORT_STD template <class _Ty, class _Alloc>
struct uses_allocator : _Has_allocator_type<_Ty, _Alloc>::type {};

_EXPORT_STD template <class _Ty, class _Alloc>
_INLINE_VAR constexpr bool uses_allocator_v = uses_allocator<_Ty, _Alloc>::value;
constexpr bool uses_allocator_v = uses_allocator<_Ty, _Alloc>::value;

// from <iterator>
_EXPORT_STD struct input_iterator_tag {};
Expand Down Expand Up @@ -386,7 +386,7 @@ struct iterator_traits<_Ty*> {
};

template <class _Ty>
inline constexpr bool _Integer_class = requires {
constexpr bool _Integer_class = requires {
typename _Ty::_Signed_type;
typename _Ty::_Unsigned_type;
};
Expand Down Expand Up @@ -418,7 +418,7 @@ concept sentinel_for = semiregular<_Se>
// clang-format on

_EXPORT_STD template <class _Se, class _It>
inline constexpr bool disable_sized_sentinel_for = false;
constexpr bool disable_sized_sentinel_for = false;

// clang-format off
_EXPORT_STD template <class _Se, class _It>
Expand Down Expand Up @@ -454,7 +454,7 @@ namespace ranges {
_EXPORT_STD using ranges::get;

template <class _It, class _Se, ranges::subrange_kind _Ki>
inline constexpr bool _Is_subrange_v<ranges::subrange<_It, _Se, _Ki>> = true;
constexpr bool _Is_subrange_v<ranges::subrange<_It, _Se, _Ki>> = true;

template <class _It, class _Se, ranges::subrange_kind _Ki>
struct tuple_size<ranges::subrange<_It, _Se, _Ki>> : integral_constant<size_t, 2> {};
Expand Down
12 changes: 6 additions & 6 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ _INLINE_VAR constexpr ptrdiff_t _Threshold_find_first_of = 16;

// Can we activate the vector algorithms for find_first_of?
template <class _It1, class _It2, class _Pr>
_INLINE_VAR constexpr bool _Vector_alg_in_find_first_of_is_safe =
constexpr bool _Vector_alg_in_find_first_of_is_safe =
_Equal_memcmp_is_safe<_It1, _It2, _Pr> // can replace value comparison with bitwise comparison
&& sizeof(_Iter_value_t<_It1>) <= 2; // pcmpestri compatible size
_STD_END
Expand All @@ -202,7 +202,7 @@ _STD_BEGIN
_INLINE_VAR constexpr int _ISORT_MAX = 32; // maximum size for insertion sort

template <class _It>
_INLINE_VAR constexpr _Iter_diff_t<_It> _Isort_max{_ISORT_MAX};
constexpr _Iter_diff_t<_It> _Isort_max{_ISORT_MAX};

template <class _Diff>
constexpr ptrdiff_t _Temporary_buffer_size(const _Diff _Value) noexcept {
Expand Down Expand Up @@ -3516,11 +3516,11 @@ namespace ranges {
_EXPORT_STD inline constexpr _Find_first_of_fn find_first_of;

template <class _Ty>
inline constexpr bool _Is_trivially_ranges_swappable_v =
constexpr bool _Is_trivially_ranges_swappable_v =
disjunction_v<conjunction<is_scalar<_Ty>, negation<is_enum<_Ty>>>, _Is_trivially_swappable<_Ty>>;

template <class _Ty, size_t _Len>
inline constexpr bool _Is_trivially_ranges_swappable_v<_Ty[_Len]> = _Is_trivially_ranges_swappable_v<_Ty>;
constexpr bool _Is_trivially_ranges_swappable_v<_Ty[_Len]> = _Is_trivially_ranges_swappable_v<_Ty>;

template <class _Ty>
struct _Is_trivially_ranges_swappable : bool_constant<_Is_trivially_ranges_swappable_v<_Ty>> {};
Expand Down Expand Up @@ -3948,7 +3948,7 @@ namespace ranges {

// TRANSITION, DevCom-10606350: help the compiler auto-vectorize for simple types
template <class _UOutIt, class _InTy, class _NewTy, class _OutTy = remove_pointer_t<_UOutIt>>
_INLINE_VAR constexpr bool _Can_vectorize_replace_copy = conjunction_v<is_pointer<_UOutIt>, is_same<_InTy, _NewTy>,
constexpr bool _Can_vectorize_replace_copy = conjunction_v<is_pointer<_UOutIt>, is_same<_InTy, _NewTy>,
disjunction<
#ifdef __cpp_lib_byte
conjunction<is_same<_InTy, byte>, is_same<_OutTy, byte>>,
Expand Down Expand Up @@ -4718,7 +4718,7 @@ template <class _InIt, class _OutIt>
#if _HAS_CXX20
concept
#else
_INLINE_VAR constexpr bool
constexpr bool
#endif
_Can_reread_dest = _Is_cpp17_fwd_iter_v<_OutIt> && is_same_v<_Iter_value_t<_InIt>, _Iter_value_t<_OutIt>>;

Expand Down
11 changes: 5 additions & 6 deletions stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public:
inline constexpr size_t _Any_trivial_space_size = (_Small_object_num_ptrs - 1) * sizeof(void*);

template <class _Ty>
inline constexpr bool _Any_is_trivial =
constexpr bool _Any_is_trivial =
alignof(_Ty) <= alignof(max_align_t) && is_trivially_copyable_v<_Ty> && sizeof(_Ty) <= _Any_trivial_space_size;

inline constexpr size_t _Any_small_space_size = (_Small_object_num_ptrs - 2) * sizeof(void*);

template <class _Ty>
inline constexpr bool _Any_is_small = alignof(_Ty) <= alignof(max_align_t)
&& is_nothrow_move_constructible_v<_Ty> && sizeof(_Ty) <= _Any_small_space_size;
constexpr bool _Any_is_small = alignof(_Ty) <= alignof(max_align_t)
&& is_nothrow_move_constructible_v<_Ty> && sizeof(_Ty) <= _Any_small_space_size;

enum class _Any_representation : uintptr_t { _Trivial, _Big, _Small };

Expand Down Expand Up @@ -97,11 +97,10 @@ struct _Any_small_RTTI { // Hand-rolled vtable for nontrivial types that can be
};

template <class _Ty>
inline constexpr _Any_big_RTTI _Any_big_RTTI_obj = {
&_Any_big_RTTI::_Destroy_impl<_Ty>, &_Any_big_RTTI::_Copy_impl<_Ty>};
constexpr _Any_big_RTTI _Any_big_RTTI_obj = {&_Any_big_RTTI::_Destroy_impl<_Ty>, &_Any_big_RTTI::_Copy_impl<_Ty>};

template <class _Ty>
inline constexpr _Any_small_RTTI _Any_small_RTTI_obj = {
constexpr _Any_small_RTTI _Any_small_RTTI_obj = {
&_Any_small_RTTI::_Destroy_impl<_Ty>, &_Any_small_RTTI::_Copy_impl<_Ty>, &_Any_small_RTTI::_Move_impl<_Ty>};

_EXPORT_STD class any { // storage for any (CopyConstructible) type
Expand Down
13 changes: 6 additions & 7 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ struct _Storage_for {

#if _CMPXCHG_MASK_OUT_PADDING_BITS
template <class _Ty>
inline constexpr bool _Might_have_non_value_bits =
!has_unique_object_representations_v<_Ty> && !is_floating_point_v<_Ty>;
constexpr bool _Might_have_non_value_bits = !has_unique_object_representations_v<_Ty> && !is_floating_point_v<_Ty>;
#endif // _CMPXCHG_MASK_OUT_PADDING_BITS

_EXPORT_STD extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept {
Expand Down Expand Up @@ -1648,22 +1647,22 @@ struct _Atomic_integral<_Ty, 8> : _Atomic_storage<_Ty> { // atomic integral oper

#if 1 // TRANSITION, ABI
template <size_t _TypeSize>
_INLINE_VAR constexpr bool _Is_always_lock_free = _TypeSize <= 8 && (_TypeSize & (_TypeSize - 1)) == 0;
constexpr bool _Is_always_lock_free = _TypeSize <= 8 && (_TypeSize & (_TypeSize - 1)) == 0;
#else // ^^^ don't break ABI / break ABI vvv
#if _ATOMIC_HAS_DCAS
template <size_t _TypeSize>
_INLINE_VAR constexpr bool _Is_always_lock_free = _TypeSize <= 2 * sizeof(void*);
constexpr bool _Is_always_lock_free = _TypeSize <= 2 * sizeof(void*);
#else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv
template <size_t _TypeSize>
_INLINE_VAR constexpr bool _Is_always_lock_free = _TypeSize <= sizeof(void*);
constexpr bool _Is_always_lock_free = _TypeSize <= sizeof(void*);
#endif // ^^^ !_ATOMIC_HAS_DCAS ^^^
#endif // ^^^ break ABI ^^^

template <class _Ty, bool _Is_lock_free = _Is_always_lock_free<sizeof(_Ty)>>
_INLINE_VAR constexpr bool _Deprecate_non_lock_free_volatile = true;
constexpr bool _Deprecate_non_lock_free_volatile = true;

template <class _Ty>
_CXX20_DEPRECATE_VOLATILE _INLINE_VAR constexpr bool _Deprecate_non_lock_free_volatile<_Ty, false> = true;
_CXX20_DEPRECATE_VOLATILE constexpr bool _Deprecate_non_lock_free_volatile<_Ty, false> = true;

template <class _Ty>
struct _Atomic_integral_facade : _Atomic_integral<_Ty> {
Expand Down
16 changes: 8 additions & 8 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ namespace chrono {
}

template <class _To, class _From>
inline constexpr bool
constexpr bool
_Duration_underflows_with = !treat_as_floating_point_v<typename _From::rep>
&& _From::period::den / _Gcd(_From::period::den, _To::period::den)
> INTMAX_MAX / (_To::period::num / _Gcd(_From::period::num, _To::period::num));
Expand Down Expand Up @@ -2872,10 +2872,10 @@ namespace chrono {
// [time.clock.cast.sys]

template <class _TimePoint, class _Clock>
inline constexpr bool _Is_time_point_for_clock = false;
constexpr bool _Is_time_point_for_clock = false;

template <class _Clock, class _Duration>
inline constexpr bool _Is_time_point_for_clock<time_point<_Clock, _Duration>, _Clock> = true;
constexpr bool _Is_time_point_for_clock<time_point<_Clock, _Duration>, _Clock> = true;

template <class _SourceClock>
struct clock_time_conversion<system_clock, _SourceClock> {
Expand Down Expand Up @@ -2947,17 +2947,17 @@ namespace chrono {
};

template <class _Conv1, class _Conv2, class _Tp, class = void>
inline constexpr bool _Has_two_step_conversion = false;
constexpr bool _Has_two_step_conversion = false;

template <class _Conv1, class _Conv2, class _Tp>
inline constexpr bool
constexpr bool
_Has_two_step_conversion<_Conv1, _Conv2, _Tp, void_t<decltype(_Conv1{}(_Conv2{}(_STD declval<_Tp>())))>> = true;

template <class _Conv1, class _Conv2, class _Conv3, class _Tp, class = void>
inline constexpr bool _Has_three_step_conversion = false;
constexpr bool _Has_three_step_conversion = false;

template <class _Conv1, class _Conv2, class _Conv3, class _Tp>
inline constexpr bool _Has_three_step_conversion<_Conv1, _Conv2, _Conv3, _Tp,
constexpr bool _Has_three_step_conversion<_Conv1, _Conv2, _Conv3, _Tp,
void_t<decltype(_Conv1{}(_Conv2{}(_Conv3{}(_STD declval<_Tp>()))))>> = true;

template <class _DestClock, class _SourceClock, class _Duration>
Expand Down Expand Up @@ -3004,7 +3004,7 @@ namespace chrono {
}

template <class _DestClock, class _SourceClock, class _Duration>
inline constexpr auto _Clock_cast_choice = _Choose_clock_cast<_DestClock, _SourceClock, _Duration>();
constexpr auto _Clock_cast_choice = _Choose_clock_cast<_DestClock, _SourceClock, _Duration>();

_EXPORT_STD template <class _DestClock, class _SourceClock, class _Duration,
enable_if_t<_Clock_cast_choice<_DestClock, _SourceClock, _Duration> != _Clock_cast_strategy::_None, int> = 0>
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ enum _Comparison_category : unsigned char {
};

template <class... _Types>
inline constexpr unsigned char _Classify_category =
constexpr unsigned char _Classify_category =
_Comparison_category{(_Classify_category<_Types> | ... | _Comparison_category_strong)};
template <class _Ty>
inline constexpr unsigned char _Classify_category<_Ty> = _Comparison_category_none;
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace _Math_algorithms {
static constexpr float value{9.2233715e+18f};
};
template <class _Ty>
_INLINE_VAR constexpr _Ty _Hypot_leg_huge = _Hypot_leg_huge_helper<_Ty>::value;
constexpr _Ty _Hypot_leg_huge = _Hypot_leg_huge_helper<_Ty>::value;

template <class _Ty>
struct _Hypot_leg_tiny_helper {
Expand All @@ -224,7 +224,7 @@ namespace _Math_algorithms {
static constexpr float value{4.440892e-16f};
};
template <class _Ty>
_INLINE_VAR constexpr _Ty _Hypot_leg_tiny = _Hypot_leg_tiny_helper<_Ty>::value;
constexpr _Ty _Hypot_leg_tiny = _Hypot_leg_tiny_helper<_Ty>::value;

template <class _Ty>
_NODISCARD _Ty _Norm_minus_one(const _Ty _Xval, const _Ty _Yval) noexcept {
Expand Down Expand Up @@ -912,7 +912,7 @@ public:
};

template <class _Ty>
_INLINE_VAR constexpr bool _Is_unqual_fp = _Is_any_of_v<_Ty, float, double, long double>;
constexpr bool _Is_unqual_fp = _Is_any_of_v<_Ty, float, double, long double>;

template <class _Ty>
struct _Complex_value {
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/execution
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ struct _Atomic_is_usually_lock_free : bool_constant<atomic<_Ty>::is_always_lock_
};

template <class _FwdIt>
inline constexpr bool _Use_atomic_iterator = conjunction_v<bool_constant<_Is_ranges_random_iter_v<_FwdIt>>,
constexpr bool _Use_atomic_iterator = conjunction_v<bool_constant<_Is_ranges_random_iter_v<_FwdIt>>,
is_trivially_copyable<_FwdIt>, _Atomic_is_usually_lock_free<_FwdIt>>;

template <class _Ty>
Expand Down
10 changes: 5 additions & 5 deletions stl/inc/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ namespace filesystem {
}

template <class _Ty, class = void>
inline constexpr bool _Is_Source_impl = false;
constexpr bool _Is_Source_impl = false;

template <class _Ty>
inline constexpr bool _Is_Source_impl<_Ty, void_t<typename iterator_traits<_Ty>::value_type>> =
constexpr bool _Is_Source_impl<_Ty, void_t<typename iterator_traits<_Ty>::value_type>> =
_Is_EcharT<typename iterator_traits<_Ty>::value_type>;

template <class _Ty>
inline constexpr bool _Is_Source = _Is_Source_impl<decay_t<_Ty>>;
constexpr bool _Is_Source = _Is_Source_impl<decay_t<_Ty>>;

_EXPORT_STD class path;

Expand All @@ -178,10 +178,10 @@ namespace filesystem {
// iterator_traits when determining if path is copyable.

template <class _Elem, class _Traits, class _Alloc>
inline constexpr bool _Is_Source<basic_string<_Elem, _Traits, _Alloc>> = _Is_EcharT<_Elem>;
constexpr bool _Is_Source<basic_string<_Elem, _Traits, _Alloc>> = _Is_EcharT<_Elem>;

template <class _Elem, class _Traits>
inline constexpr bool _Is_Source<basic_string_view<_Elem, _Traits>> = _Is_EcharT<_Elem>;
constexpr bool _Is_Source<basic_string_view<_Elem, _Traits>> = _Is_EcharT<_Elem>;

struct _Normal_conversion {};

Expand Down
Loading

0 comments on commit d7e4c4c

Please sign in to comment.