Fix c++17 build failure

This commit is contained in:
rexy712 2022-06-24 23:02:27 -07:00
parent 5ce29908df
commit 329a79c3ea
2 changed files with 63 additions and 8 deletions

View File

@ -30,7 +30,8 @@ namespace rexy::cx{
#include "../string_view.hpp" #include "../string_view.hpp"
#include "../utility.hpp" //strlen, strcmp #include "../utility.hpp" //strlen, strcmp
#include "../detail/string_appender.hpp" #include "../detail/string_appender.hpp"
#include <type_traits> //nothrow_invocable, integral_constant, declval, remove_cvref_t #include "../traits.hpp" //remove_cvref
#include <type_traits> //nothrow_invocable, integral_constant, declval
#include <iterator> //reverse_iterator #include <iterator> //reverse_iterator
#include "../compat/standard.hpp" #include "../compat/standard.hpp"
@ -224,7 +225,7 @@ namespace rexy::cx{
template<class Char, std::size_t N> template<class Char, std::size_t N>
static std::true_type check(cx::string<N,Char>); static std::true_type check(cx::string<N,Char>);
static std::false_type check(...); static std::false_type check(...);
static constexpr bool value = (decltype(check(std::declval<std::remove_cvref_t<Ts>>()))::value && ...); static constexpr bool value = (decltype(check(std::declval<remove_cvref_t<Ts>>()))::value && ...);
}; };
} }

View File

@ -54,6 +54,60 @@ namespace rexy{
static constexpr bool value = std::is_same<std::true_type,decltype(test(static_cast<std::decay_t<T>*>(nullptr)))>::value; static constexpr bool value = std::is_same<std::true_type,decltype(test(static_cast<std::decay_t<T>*>(nullptr)))>::value;
}; };
#ifdef REXY_STANDARD_CPP20
template<class T>
struct remove_cvref : public std::remove_cvref<T>{};
template<class T>
using remove_cvref_t = typename remove_cvref<T>::type;
#else // REXY_STANDARD_CPP26
template<class T>
struct remove_volatile{
using type = T;
};
template<class T>
struct remove_volatile<volatile T>{
using type = T;
};
template<class T>
using remove_volatile_t = typename remove_volatile<T>::type;
template<class T>
struct remove_const{
using type = T;
};
template<class T>
struct remove_const<const T>{
using type = T;
};
template<class T>
using remove_const_t = typename remove_const<T>::type;
template<class T>
struct remove_cv{
using type = remove_volatile_t<remove_const_t<T>>;
};
template<class T>
using remove_cv_t = typename remove_cv<T>::type;
template<class T>
struct remove_reference{
using type = T;
};
template<class T>
struct remove_reference<T&>{
using type = T;
};
template<class T>
struct remove_reference<T&&>{
using type = T;
};
template<class T>
using remove_reference_t = typename remove_reference<T>::type;
template<class T>
struct remove_cvref{
using type = remove_cv_t<remove_reference_t<T>>;
};
template<class T>
using remove_cvref_t = typename remove_cvref<T>::type;
#endif // REXY_STANDARD_CPP26
template<class T, class = void> template<class T, class = void>
struct is_dereferencable : public std::false_type{}; struct is_dereferencable : public std::false_type{};
template<class T> template<class T>
@ -73,14 +127,14 @@ namespace rexy{
template<class T, class = void> template<class T, class = void>
struct is_prefix_incrementable : public std::false_type{}; struct is_prefix_incrementable : public std::false_type{};
template<class T> template<class T>
struct is_prefix_incrementable<T,std::void_t<decltype(++(std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>()))>> : public std::true_type{}; struct is_prefix_incrementable<T,std::void_t<decltype(++(std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>()))>> : public std::true_type{};
template<class T> template<class T>
static constexpr bool is_prefix_incrementable_v = is_prefix_incrementable<T>::value; static constexpr bool is_prefix_incrementable_v = is_prefix_incrementable<T>::value;
template<class T, class = void> template<class T, class = void>
struct is_postfix_incrementable : public std::false_type{}; struct is_postfix_incrementable : public std::false_type{};
template<class T> template<class T>
struct is_postfix_incrementable<T,std::void_t<decltype((std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>())++)>> : public std::true_type{}; struct is_postfix_incrementable<T,std::void_t<decltype((std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>())++)>> : public std::true_type{};
template<class T> template<class T>
static constexpr bool is_postfix_incrementable_v = is_postfix_incrementable<T>::value; static constexpr bool is_postfix_incrementable_v = is_postfix_incrementable<T>::value;
@ -115,8 +169,8 @@ namespace rexy{
struct is_legacy_input_iterator<T,true>{ struct is_legacy_input_iterator<T,true>{
static constexpr bool value = std::is_convertible_v<decltype(std::declval<T>() == std::declval<T>()),bool> && static constexpr bool value = std::is_convertible_v<decltype(std::declval<T>() == std::declval<T>()),bool> &&
std::is_same_v<decltype(*(std::declval<T>())),typename std::iterator_traits<T>::reference> && std::is_same_v<decltype(*(std::declval<T>())),typename std::iterator_traits<T>::reference> &&
std::is_same_v<decltype(++std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>()),std::add_lvalue_reference_t<T>> && std::is_same_v<decltype(++std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>()),std::add_lvalue_reference_t<T>> &&
std::is_convertible_v<decltype(*std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>()++), typename std::iterator_traits<T>::value_type>; std::is_convertible_v<decltype(*std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>()++), typename std::iterator_traits<T>::value_type>;
}; };
template<class T> template<class T>
static constexpr bool is_legacy_input_iterator_v = is_legacy_input_iterator<T>::value; static constexpr bool is_legacy_input_iterator_v = is_legacy_input_iterator<T>::value;
@ -128,8 +182,8 @@ namespace rexy{
template<class T, class Value> template<class T, class Value>
struct is_legacy_output_iterator<T,Value,true>{ struct is_legacy_output_iterator<T,Value,true>{
static constexpr bool value = static constexpr bool value =
std::is_same_v<decltype(++std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>()),std::add_lvalue_reference_t<T>> && std::is_same_v<decltype(++std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>()),std::add_lvalue_reference_t<T>> &&
std::is_convertible_v<decltype(std::declval<std::add_lvalue_reference_t<std::remove_cvref_t<T>>>()++), std::add_lvalue_reference_t<std::add_const_t<T>>>; std::is_convertible_v<decltype(std::declval<std::add_lvalue_reference_t<remove_cvref_t<T>>>()++), std::add_lvalue_reference_t<std::add_const_t<T>>>;
}; };
template<class T, class Value> template<class T, class Value>
static constexpr bool is_legacy_output_iterator_v = is_legacy_output_iterator<T,Value>::value; static constexpr bool is_legacy_output_iterator_v = is_legacy_output_iterator<T,Value>::value;