mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add identity
This commit is contained in:
parent
2cb55b6b6c
commit
a2b368a7cc
11 changed files with 85 additions and 63 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -11,7 +12,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T, typename Compare>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
clamp(T const& value, typename std::common_type<T>::type const& low, typename std::common_type<T>::type const& high, Compare comp) {
|
||||
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high, Compare comp) {
|
||||
return comp(value, low) ? low
|
||||
: comp(high, value) ? high
|
||||
: value
|
||||
|
@ -19,7 +20,7 @@ namespace sprout {
|
|||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
clamp(T const& value, typename std::common_type<T>::type const& low, typename std::common_type<T>::type const& high) {
|
||||
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high) {
|
||||
return sprout::clamp(
|
||||
value, low, high,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::less<T>()
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type_traits/common_decay.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -23,12 +24,12 @@ namespace sprout {
|
|||
//
|
||||
template<typename... Types>
|
||||
inline SPROUT_CONSTEXPR sprout::array<
|
||||
typename std::decay<typename std::common_type<typename std::decay<Types>::type...>::type>::type,
|
||||
typename sprout::common_decay<typename std::decay<Types>::type...>::type,
|
||||
sizeof...(Types)
|
||||
>
|
||||
make_common_array(Types&&... args) {
|
||||
typedef sprout::array<
|
||||
typename std::decay<typename std::common_type<typename std::decay<Types>::type...>::type>::type,
|
||||
typename sprout::common_decay<typename std::decay<Types>::type...>::type,
|
||||
sizeof...(Types)
|
||||
> type;
|
||||
return type{{sprout::forward<Types>(args)...}};
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<std::size_t N>
|
||||
struct size_t_
|
||||
: public std::integral_constant<std::size_t, N>
|
||||
template<typename T>
|
||||
struct sizeof_
|
||||
: public std::integral_constant<std::size_t, sizeof(T)>
|
||||
{};
|
||||
|
||||
struct base_bitset_from_words_construct_tag {};
|
||||
|
@ -78,15 +78,15 @@ namespace sprout {
|
|||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichword(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbyte(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return (pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)) / CHAR_BIT;
|
||||
return (pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)) / CHAR_BIT;
|
||||
}
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbit(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
static SPROUT_CONSTEXPR word_type
|
||||
maskbit(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
|
@ -103,7 +103,7 @@ namespace sprout {
|
|||
{
|
||||
return first == last ? not_found
|
||||
: *first != static_cast<word_type>(0)
|
||||
? i * (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) + sprout::ctz(*first)
|
||||
? i * (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) + sprout::ctz(*first)
|
||||
: find_first_impl(not_found, first + 1, last, i + 1)
|
||||
;
|
||||
}
|
||||
|
@ -115,14 +115,14 @@ namespace sprout {
|
|||
{
|
||||
return first == last ? not_found
|
||||
: *first != static_cast<word_type>(0)
|
||||
? i * (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) + sprout::ctz(*first)
|
||||
? i * (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) + sprout::ctz(*first)
|
||||
: find_next_impl_2(not_found, first + 1, last)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR std::size_t
|
||||
find_next_impl_1(std::size_t not_found, std::size_t i, word_type thisword) const SPROUT_NOEXCEPT {
|
||||
return thisword != static_cast<word_type>(0)
|
||||
? i * (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) + sprout::ctz(thisword)
|
||||
? i * (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) + sprout::ctz(thisword)
|
||||
: find_next_impl_2(not_found, begin() + (i + 1), end(), i + 1)
|
||||
;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ namespace sprout {
|
|||
sprout::index_range<0, N>::make()
|
||||
)
|
||||
: do_left_shift_impl_2(
|
||||
wshift, offset, (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - offset,
|
||||
wshift, offset, (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - offset,
|
||||
sprout::index_range<0, N>::make()
|
||||
)
|
||||
;
|
||||
|
@ -212,7 +212,7 @@ namespace sprout {
|
|||
sprout::index_range<0, N>::make()
|
||||
)
|
||||
: do_right_shift_impl_2(
|
||||
wshift, offset, limit, (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - offset,
|
||||
wshift, offset, limit, (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - offset,
|
||||
sprout::index_range<0, N>::make()
|
||||
)
|
||||
;
|
||||
|
@ -222,7 +222,7 @@ namespace sprout {
|
|||
: w_()
|
||||
{}
|
||||
SPROUT_CONSTEXPR base_bitset(unsigned long long val) SPROUT_NOEXCEPT
|
||||
: w_{word_type(val), word_type(val >> (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value))}
|
||||
: w_{word_type(val), word_type(val >> (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value))}
|
||||
{}
|
||||
template<typename... Words>
|
||||
SPROUT_CONSTEXPR base_bitset(sprout::detail::base_bitset_from_words_construct_tag, Words... words)
|
||||
|
@ -302,14 +302,14 @@ namespace sprout {
|
|||
void
|
||||
do_left_shift(std::size_t shift) SPROUT_NOEXCEPT {
|
||||
if (shift != 0) {
|
||||
std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
std::size_t const offset = shift % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
std::size_t const offset = shift % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
if (offset == 0) {
|
||||
for (std::size_t n = N - 1; n >= wshift; --n) {
|
||||
w_[n] = w_[n - wshift];
|
||||
}
|
||||
} else {
|
||||
std::size_t const sub_offset = (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - offset;
|
||||
std::size_t const sub_offset = (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - offset;
|
||||
for (std::size_t n = N - 1; n > wshift; --n) {
|
||||
w_[n] = (w_[n - wshift] << offset) | (w_[n - wshift - 1] >> sub_offset);
|
||||
}
|
||||
|
@ -321,8 +321,8 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR base_bitset<N>
|
||||
do_left_shift(std::size_t shift) const SPROUT_NOEXCEPT {
|
||||
return shift != 0 ? do_left_shift_impl(
|
||||
shift / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value),
|
||||
shift % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)
|
||||
shift / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value),
|
||||
shift % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)
|
||||
)
|
||||
: *this
|
||||
;
|
||||
|
@ -330,15 +330,15 @@ namespace sprout {
|
|||
void
|
||||
do_right_shift(std::size_t shift) SPROUT_NOEXCEPT {
|
||||
if (shift != 0) {
|
||||
std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
std::size_t const offset = shift % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
std::size_t const offset = shift % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
std::size_t const limit = N - wshift - 1;
|
||||
if (offset == 0) {
|
||||
for (std::size_t n = 0; n <= limit; ++n) {
|
||||
w_[n] = w_[n + wshift];
|
||||
}
|
||||
} else {
|
||||
std::size_t const sub_offset = (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - offset;
|
||||
std::size_t const sub_offset = (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - offset;
|
||||
for (std::size_t n = 0; n < limit; ++n) {
|
||||
w_[n] = (w_[n + wshift] >> offset) | (w_[n + wshift + 1] << sub_offset);
|
||||
}
|
||||
|
@ -350,9 +350,9 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR base_bitset<N>
|
||||
do_right_shift(std::size_t shift) const SPROUT_NOEXCEPT {
|
||||
return shift != 0 ? do_right_shift_impl(
|
||||
shift / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value),
|
||||
shift % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value),
|
||||
N - shift / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - 1
|
||||
shift / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value),
|
||||
shift % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value),
|
||||
N - shift / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - 1
|
||||
)
|
||||
: *this
|
||||
;
|
||||
|
@ -385,7 +385,7 @@ namespace sprout {
|
|||
}
|
||||
void
|
||||
do_reset() SPROUT_NOEXCEPT {
|
||||
std::memset(w_, 0, N * sprout::detail::size_t_<sizeof(word_type)>::value);
|
||||
std::memset(w_, 0, N * sprout::detail::sizeof_<word_type>::value);
|
||||
}
|
||||
|
||||
SPROUT_CONSTEXPR bool
|
||||
|
@ -396,7 +396,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR bool
|
||||
are_all() const SPROUT_NOEXCEPT {
|
||||
return sprout::all_of(begin(), end() - 1, are_all_pred())
|
||||
&& hiword() == (~static_cast<word_type>(0) >> (N * (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) - N2))
|
||||
&& hiword() == (~static_cast<word_type>(0) >> (N * (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) - N2))
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool
|
||||
|
@ -418,14 +418,14 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR unsigned long long
|
||||
do_to_ullong() const {
|
||||
return sprout::find_if(
|
||||
sprout::detail::size_t_<sizeof(unsigned long long)>::value > sprout::detail::size_t_<sizeof(unsigned long)>::value ? begin() + 2
|
||||
sprout::detail::sizeof_<unsigned long long>::value > sprout::detail::sizeof_<unsigned long>::value ? begin() + 2
|
||||
: begin() + 1
|
||||
,
|
||||
end(),
|
||||
to_ulong_pred()
|
||||
) != end()
|
||||
? throw std::overflow_error("base_bitset::to_ullong")
|
||||
: sprout::detail::size_t_<sizeof(unsigned long long)>::value > sprout::detail::size_t_<sizeof(unsigned long)>::value
|
||||
: sprout::detail::sizeof_<unsigned long long>::value > sprout::detail::sizeof_<unsigned long>::value
|
||||
? w_[0] + (static_cast<unsigned long long>(w_[1]) << (CHAR_BIT * sizeof(unsigned long)))
|
||||
: w_[0]
|
||||
;
|
||||
|
@ -437,7 +437,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR std::size_t
|
||||
find_next(std::size_t prev, std::size_t not_found) const SPROUT_NOEXCEPT {
|
||||
return prev + 1 >= N * (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) ? not_found
|
||||
return prev + 1 >= N * (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) ? not_found
|
||||
: find_next_impl(prev + 1, not_found, whichword(prev + 1));
|
||||
;
|
||||
}
|
||||
|
@ -475,15 +475,15 @@ namespace sprout {
|
|||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichword(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbyte(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return (pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)) / CHAR_BIT;
|
||||
return (pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)) / CHAR_BIT;
|
||||
}
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbit(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
static SPROUT_CONSTEXPR word_type
|
||||
maskbit(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
|
@ -641,7 +641,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR std::size_t
|
||||
find_next(std::size_t prev, std::size_t not_found) const SPROUT_NOEXCEPT {
|
||||
return prev + 1 >= static_cast<std::size_t>(CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) ? not_found
|
||||
return prev + 1 >= static_cast<std::size_t>(CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) ? not_found
|
||||
: find_next_impl(prev + 1, not_found, w_ >> (prev + 1))
|
||||
;
|
||||
}
|
||||
|
@ -658,17 +658,17 @@ namespace sprout {
|
|||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichword(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbyte(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return (pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)) / CHAR_BIT;
|
||||
return (pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)) / CHAR_BIT;
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
whichbit(std::size_t pos) SPROUT_NOEXCEPT {
|
||||
return pos % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value);
|
||||
return pos % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR word_type
|
||||
|
@ -821,7 +821,7 @@ namespace sprout {
|
|||
}
|
||||
};
|
||||
|
||||
template<std::size_t N2, bool = (N2 < (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long long)>::value))>
|
||||
template<std::size_t N2, bool = (N2 < (CHAR_BIT * sprout::detail::sizeof_<unsigned long long>::value))>
|
||||
struct sanitize_val {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR unsigned long long
|
||||
|
@ -892,12 +892,12 @@ namespace sprout {
|
|||
template<std::size_t N>
|
||||
class bitset
|
||||
: private sprout::detail::base_bitset<
|
||||
N / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) + (N % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) == 0 ? 0 : 1)
|
||||
N / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) + (N % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) == 0 ? 0 : 1)
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef sprout::detail::base_bitset<
|
||||
N / (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) + (N % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value) == 0 ? 0 : 1)
|
||||
N / (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) + (N % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value) == 0 ? 0 : 1)
|
||||
> base_type;
|
||||
typedef unsigned long word_type;
|
||||
public:
|
||||
|
@ -955,12 +955,12 @@ namespace sprout {
|
|||
|
||||
void
|
||||
do_sanitize() SPROUT_NOEXCEPT {
|
||||
typedef sprout::detail::sanitize<N % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)> sanitize_type;
|
||||
typedef sprout::detail::sanitize<N % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)> sanitize_type;
|
||||
sanitize_type::do_sanitize(this->hiword());
|
||||
}
|
||||
SPROUT_CONSTEXPR bitset<N>
|
||||
do_sanitize() const SPROUT_NOEXCEPT {
|
||||
typedef sprout::detail::sanitize<N % (CHAR_BIT * sprout::detail::size_t_<sizeof(unsigned long)>::value)> sanitize_type;
|
||||
typedef sprout::detail::sanitize<N % (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value)> sanitize_type;
|
||||
return bitset(this->hiword(sanitize_type::do_sanitize_c(this->hiword())));
|
||||
}
|
||||
SPROUT_CONSTEXPR bitset<N>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/internal.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace containers {
|
||||
|
@ -18,10 +19,9 @@ namespace sprout {
|
|||
struct deep_internal_impl<
|
||||
Container, Prev,
|
||||
typename std::enable_if<std::is_same<Container, Prev&&>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef Container type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<Container>
|
||||
{};
|
||||
} // namespace detail
|
||||
//
|
||||
// deep_internal
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/category.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/common_decay.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -53,7 +55,7 @@ namespace sprout {
|
|||
struct min_iterator_category;
|
||||
template<typename Category>
|
||||
struct min_iterator_category<Category>
|
||||
: public std::common_type<Category>
|
||||
: public sprout::identity<Category>
|
||||
{};
|
||||
template<typename Category1, typename Category2>
|
||||
struct min_iterator_category<Category1, Category2>
|
||||
|
@ -106,10 +108,10 @@ namespace sprout {
|
|||
)
|
||||
,
|
||||
T,
|
||||
typename std::decay<typename std::common_type<typename std::decay<T>::type, typename std::decay<U>::type>::type>::type
|
||||
typename sprout::common_decay<typename std::decay<T>::type, typename std::decay<U>::type>::type
|
||||
>::type
|
||||
>::type,
|
||||
typename std::decay<typename std::common_type<typename std::decay<T>::type, typename std::decay<U>::type>::type>::type
|
||||
typename sprout::common_decay<typename std::decay<T>::type, typename std::decay<U>::type>::type
|
||||
>
|
||||
{};
|
||||
template<typename T, typename U, typename... Tail>
|
||||
|
@ -155,9 +157,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename... Iterators>
|
||||
struct common_iterator_difference_type
|
||||
: public std::decay<
|
||||
typename std::common_type<typename std::iterator_traits<Iterators>::difference_type...>::type
|
||||
>
|
||||
: public sprout::common_decay<typename std::iterator_traits<Iterators>::difference_type...>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -91,7 +92,7 @@ namespace sprout {
|
|||
}
|
||||
template<typename Difference>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::step_holder<Difference>
|
||||
operator()(Difference width, typename std::common_type<Difference>::type init) const {
|
||||
operator()(Difference width, typename sprout::identity<Difference>::type init) const {
|
||||
return sprout::adaptors::step_holder<Difference>(width, init);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sprout/type_traits/is_uint.hpp>
|
||||
#include <sprout/type_traits/is_char_type.hpp>
|
||||
#include <sprout/type_traits/is_c_str.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/type_traits/const_reference.hpp>
|
||||
#include <sprout/type_traits/common_decay.hpp>
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
struct arithmetic_promote1
|
||||
: public std::common_type<T>
|
||||
: public sprout::identity<T>
|
||||
{
|
||||
static_assert(
|
||||
std::is_arithmetic<T>::value,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -10,8 +11,8 @@ namespace sprout {
|
|||
struct float_promote1
|
||||
: public std::conditional<
|
||||
std::is_floating_point<T>::value,
|
||||
std::common_type<T>,
|
||||
std::common_type<double>
|
||||
sprout::identity<T>,
|
||||
sprout::identity<double>
|
||||
>::type
|
||||
{
|
||||
static_assert(
|
||||
|
@ -24,7 +25,7 @@ namespace sprout {
|
|||
struct float_promote2
|
||||
: public std::conditional<
|
||||
(std::is_same<T, long double>::value || std::is_same<U, long double>::value),
|
||||
std::common_type<long double>,
|
||||
sprout::identity<long double>,
|
||||
typename std::conditional<
|
||||
(std::is_same<T, float>::value && std::is_same<U, float>::value),
|
||||
float,
|
||||
|
|
17
sprout/type_traits/identity.hpp
Normal file
17
sprout/type_traits/identity.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef SPROUT_TYPE_TRAITS_IDENTITY_HPP
|
||||
#define SPROUT_TYPE_TRAITS_IDENTITY_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// identity
|
||||
//
|
||||
template<typename T>
|
||||
struct identity {
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_IDENTITY_HPP
|
|
@ -12,6 +12,7 @@
|
|||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
#include <sprout/type_traits/common_decay.hpp>
|
||||
#include <sprout/type/type_tuple.hpp>
|
||||
#include <sprout/type/algorithm/find_index.hpp>
|
||||
#include <sprout/functional/type_traits/has_type.hpp>
|
||||
|
@ -89,10 +90,8 @@ namespace sprout {
|
|||
template<typename Visitor, typename Tuple, sprout::index_t... Indexes>
|
||||
struct visitor_result_impl_1<Visitor, Tuple, sprout::index_tuple<Indexes...> > {
|
||||
public:
|
||||
typedef typename std::decay<
|
||||
typename std::common_type<
|
||||
decltype((std::declval<Visitor>())(sprout::tuples::get<Indexes>(std::declval<Tuple>())))...
|
||||
>::type
|
||||
typedef typename sprout::common_decay<
|
||||
decltype((std::declval<Visitor>())(sprout::tuples::get<Indexes>(std::declval<Tuple>())))...
|
||||
>::type type;
|
||||
};
|
||||
template<typename Visitor, typename Tuple, typename = void>
|
||||
|
|
Loading…
Reference in a new issue