Separate versioning compat in traits
This commit is contained in:
parent
329a79c3ea
commit
5a6d7023ac
73
include/rexy/compat/cpp17/traits.hpp
Normal file
73
include/rexy/compat/cpp17/traits.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
This file is a part of rexy's general purpose library
|
||||
Copyright (C) 2022 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REXY_COMPAT_CPP17_TRAITS_HPP
|
||||
#define REXY_COMPAT_CPP17_TRAITS_HPP
|
||||
|
||||
namespace rexy{
|
||||
|
||||
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
|
||||
33
include/rexy/compat/cpp20/traits.hpp
Normal file
33
include/rexy/compat/cpp20/traits.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
This file is a part of rexy's general purpose library
|
||||
Copyright (C) 2022 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REXY_COMPAT_CPP17_TRAITS_HPP
|
||||
#define REXY_COMPAT_CPP17_TRAITS_HPP
|
||||
|
||||
#include <type_traits> //remove_cvref
|
||||
|
||||
namespace rexy{
|
||||
|
||||
template<class T>
|
||||
struct remove_cvref : public std::remove_cvref<T>{};
|
||||
template<class T>
|
||||
using remove_cvref_t = typename remove_cvref<T>::type;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
29
include/rexy/compat/traits.hpp
Normal file
29
include/rexy/compat/traits.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
This file is a part of rexy's general purpose library
|
||||
Copyright (C) 2022 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REXY_COMPAT_TRAITS_HPP
|
||||
#define REXY_COMPAT_TRAITS_HPP
|
||||
|
||||
#ifdef REXY_STANDARD_CPP20
|
||||
#include "cpp20/traits.hpp"
|
||||
#else // REXY_STANDARD_CPP26
|
||||
#include "cpp17/traits.hpp"
|
||||
#endif // REXY_STANDARD_CPP26
|
||||
|
||||
|
||||
#endif
|
||||
@ -1,6 +1,6 @@
|
||||
/**
|
||||
This file is a part of rexy's general purpose library
|
||||
Copyright (C) 2020 rexy712
|
||||
Copyright (C) 2020-2022 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -22,6 +22,7 @@
|
||||
#include <type_traits> //is_same, decay, integral_constant, declval
|
||||
#include <iterator> //iterator_traits
|
||||
|
||||
#include "compat/traits.hpp"
|
||||
#include "rexy.hpp"
|
||||
|
||||
namespace rexy{
|
||||
@ -54,59 +55,6 @@ namespace rexy{
|
||||
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>
|
||||
struct is_dereferencable : public std::false_type{};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user