11 DISABLE_COMPILER_MSC_WARNING_START (4996);
12 DISABLE_COMPILER_GCC_WARNING_START (
"GCC diagnostic ignored \"-Wdeprecated-declarations\"");
13 DISABLE_COMPILER_CLANG_WARNING_START (
"clang diagnostic ignored \"-Wdeprecated-declarations\"");
15 [[deprecated (
"Since Stroika v3.0d1, use IEqualToOptimizable concept")]]
constexpr bool HasUsableEqualToOptimization ()
17 return IEqualToOptimizable<T>;
21 [[deprecated (
"Since Stroika v3.0d1, use require expression")]]
constexpr inline bool has_plus_v =
requires (T t) {
25 template <
typename From,
typename To>
26 struct is_explicitly_convertible {
30 template <
typename F,
typename T>
31 static constexpr auto test (
int) ->
decltype (f (
static_cast<T
> (declval<F> ())),
true)
36 template <
typename F,
typename T>
37 static constexpr auto test (...) ->
bool
42 static bool const value = test<From, To> (0);
45 template <
typename From,
typename To>
46 [[deprecated (
"Since Stroika v3.0d1 - not sure any point - probalyuse convertible or constructible concepts")]]
constexpr inline bool is_explicitly_convertible_v =
47 Private_::is_explicitly_convertible<From, To>::value;
50 [[deprecated (
"Since Stroika v3.0d1, use IHasSizeMethod")]]
constexpr inline bool has_size_v = IHasSizeMethod<T>;
54 using has_beginend_t =
decltype (
static_cast<bool> (begin (declval<T&> ()) != end (declval<T&> ())));
57 [[deprecated (
"Since Stroika v3.0d1, use std::ranges::range (probably - roughly same)")]]
constexpr inline bool has_beginend_v =
58 is_detected_v<Private_::has_beginend_t, T>;
62 using has_minus_t =
decltype (std::declval<T> () - std::declval<T> ());
65 [[deprecated (
"Since Stroika v3.0d1, use something else, either requires statment, or random_access_iterator for "
66 "example")]]
constexpr inline bool has_minus_v = is_detected_v<Private_::has_minus_t, T>;
67 template <
typename T,
typename U>
68 [[deprecated (
"Since Stroika v3.0d1, use something else, either requires statment, or random_access_iterator for "
69 "example")]]
constexpr inline bool has_minus_v<std::pair<T, U>> = has_minus_v<T> and has_minus_v<U>;
70 template <
typename... Ts>
71 [[deprecated (
"Since Stroika v3.0d1, use something else, either requires statment, or random_access_iterator for "
72 "example")]]
constexpr inline bool has_minus_v<std::tuple<Ts...>> = (has_minus_v<Ts> and ...);
75 using has_neq_t =
decltype (
static_cast<bool> (std::declval<T> () != std::declval<T> ()));
78 [[deprecated (
"Since Stroika v3.0d1, use equality_comparable (cuz in C++20 basically same) concept")]]
constexpr inline bool has_neq_v =
79 is_detected_v<Private_::has_neq_t, T>;
80 template <
typename T,
typename U>
81 [[deprecated (
"Since Stroika v3.0d1, use equality_comparable (cuz in C++20 basically same) concept")]]
constexpr inline bool has_neq_v<std::pair<T, U>> =
82 has_neq_v<T> and has_neq_v<U>;
83 template <
typename... Ts>
84 [[deprecated (
"Since Stroika v3.0d1, use equality_comparable (cuz in C++20 basically same) concept")]]
constexpr inline bool has_neq_v<std::tuple<Ts...>> =
85 (has_neq_v<Ts> and ...);
88 [[deprecated (
"Since Stroika v3.0d1, use equality_comparable concept")]]
constexpr inline bool has_eq_v = equality_comparable<T>;
91 [[deprecated (
"Since Stroika v3.0d1, use totally_ordered concept")]]
constexpr inline bool has_lt_v = totally_ordered<T>;
94 [[deprecated (
"Since Stroika v3.0d1, use IHasValueType concept")]]
constexpr inline bool has_value_type_v = IHasValueType<T>;
96 [[deprecated (
"Since Stroika v3.0d1, use https://en.cppreference.com/w/cpp/concepts/equality_comparable")]]
constexpr bool EqualityComparable ()
98 return equality_comparable<T>;
101 template <
typename T>
102 [[deprecated (
"Since Stroika v3.0d1, use https://en.cppreference.com/w/cpp/concepts/totally_ordered - NOT SAME THING AT ALL, BUT "
103 "CLOSEST IN STANDARD")]]
constexpr bool
104 LessThanComparable ()
111 template <
typename T>
112 struct is_callable_impl_ {
114 typedef char (&yes)[1];
115 typedef char (&no)[2];
120 struct Derived : T, Fallback {};
122 template <
typename U, U>
126 static yes test (...);
128 template <
typename C>
129 static no test (Check<
void (Fallback::*) (), &C::operator()>*);
132 static const bool value =
sizeof (test<Derived> (0)) ==
sizeof (yes);
134 template <
typename T>
135 using is_callable = conditional_t<is_class_v<T>, is_callable_impl_<T>, false_type>;
137 template <
typename T>
138 [[deprecated (
"Since Stroika v3.0d1, use https://en.cppreference.com/w/cpp/concepts/invocable")]]
constexpr bool is_callable_v =
139 Private_::is_callable<T>::value;
140 template <
typename ITERABLE>
141 [[deprecated (
"Since Stroika v3.0d1, use ranges::range")]]
constexpr bool IsIterable_v =
142 has_beginend_v<ITERABLE> and not same_as<ExtractValueType_t<ITERABLE>,
void>;
147 template <
typename ITERABLE_OF_T,
typename T>
148 struct IsIterableOfT_Impl2_ {
149 template <
typename X,
typename USE_ITERABLE = ITERABLE_OF_T,
150 bool ITER_RESULT_CONVERTIBLE_TO_T = is_convertible_v<decltype (*begin (declval<USE_ITERABLE&> ())), T>>
151 static auto check (
const X& x)
152 -> conditional_t<is_detected_v<has_beginend_t, ITERABLE_OF_T> and ITER_RESULT_CONVERTIBLE_TO_T, substitution_succeeded<T>, substitution_failure>;
153 static substitution_failure check (...);
154 using type =
decltype (check (declval<T> ()));
156 template <
typename ITERABLE_OF_T,
typename T>
157 using IsIterableOfT_t = integral_constant<bool, not same_as<typename IsIterableOfT_Impl2_<ITERABLE_OF_T, T>::type, substitution_failure>>;
159 template <
typename ITERABLE_OF_T,
typename T>
160 [[deprecated (
"Since Stroika v3.0d1 use Traversal::IIterableOfTo concept")]]
constexpr bool IsIterableOfT_v =
161 Private_::IsIterableOfT_t<ITERABLE_OF_T, T>::value;
164 template <
typename T,
typename =
void>
166 static constexpr bool value =
false;
168 template <
typename T>
169 struct is_iterator<T, enable_if_t<!same_as<typename iterator_traits<T>::value_type, void>>> {
170 static constexpr bool value =
true;
173 template <
typename T>
174 [[deprecated (
"Since Stroika v3.0d1, use input_iterator, forward_iterator, or some other sort of std iterator concept")]]
constexpr bool IsIterator_v =
175 Private_::is_iterator<remove_cvref_t<T>>::value;
177 template <
typename FUNCTOR_ARG,
typename FUNCTOR>
178 [[deprecated (
"Since Stroika v3.0d1, use std::predicate<F,ARG,ARG>")]]
constexpr bool IsTPredicate ()
180 using T = remove_cvref_t<FUNCTOR_ARG>;
181 if constexpr (is_invocable_v<FUNCTOR, T>) {
182 return std::is_convertible_v<std::invoke_result_t<FUNCTOR, T>,
bool>;
186 template <
typename T>
187 [[deprecated (
"Since Stroika v3.0d1, use three_way_comparable")]]
constexpr inline bool has_spaceship_v = three_way_comparable<T>;
188 DISABLE_COMPILER_MSC_WARNING_END (4996);
189 DISABLE_COMPILER_GCC_WARNING_END (
"GCC diagnostic ignored \"-Wdeprecated-declarations\"");
190 DISABLE_COMPILER_CLANG_WARNING_END (
"clang diagnostic ignored \"-Wdeprecated-declarations\"");