diff --git a/sprout/algorithm/clamp.hpp b/sprout/algorithm/clamp.hpp index 81188e80..6b99f990 100644 --- a/sprout/algorithm/clamp.hpp +++ b/sprout/algorithm/clamp.hpp @@ -3,6 +3,7 @@ #include #include +#include #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT namespace sprout { @@ -11,7 +12,7 @@ namespace sprout { // template inline SPROUT_CONSTEXPR T const& - clamp(T const& value, typename std::common_type::type const& low, typename std::common_type::type const& high, Compare comp) { + clamp(T const& value, typename sprout::identity::type const& low, typename sprout::identity::type const& high, Compare comp) { return comp(value, low) ? low : comp(high, value) ? high : value @@ -19,7 +20,7 @@ namespace sprout { } template inline SPROUT_CONSTEXPR T const& - clamp(T const& value, typename std::common_type::type const& low, typename std::common_type::type const& high) { + clamp(T const& value, typename sprout::identity::type const& low, typename sprout::identity::type const& high) { return sprout::clamp( value, low, high, NS_SSCRISK_CEL_OR_SPROUT::less() diff --git a/sprout/array/make_array.hpp b/sprout/array/make_array.hpp index 46b6c128..b7bb4496 100644 --- a/sprout/array/make_array.hpp +++ b/sprout/array/make_array.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace sprout { // @@ -23,12 +24,12 @@ namespace sprout { // template inline SPROUT_CONSTEXPR sprout::array< - typename std::decay::type...>::type>::type, + typename sprout::common_decay::type...>::type, sizeof...(Types) > make_common_array(Types&&... args) { typedef sprout::array< - typename std::decay::type...>::type>::type, + typename sprout::common_decay::type...>::type, sizeof...(Types) > type; return type{{sprout::forward(args)...}}; diff --git a/sprout/bitset/bitset.hpp b/sprout/bitset/bitset.hpp index 44f04837..e17f4d4b 100644 --- a/sprout/bitset/bitset.hpp +++ b/sprout/bitset/bitset.hpp @@ -27,9 +27,9 @@ namespace sprout { namespace detail { - template - struct size_t_ - : public std::integral_constant + template + struct sizeof_ + : public std::integral_constant {}; 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_::value); + return pos / (CHAR_BIT * sprout::detail::sizeof_::value); } static SPROUT_CONSTEXPR std::size_t whichbyte(std::size_t pos) SPROUT_NOEXCEPT { - return (pos % (CHAR_BIT * sprout::detail::size_t_::value)) / CHAR_BIT; + return (pos % (CHAR_BIT * sprout::detail::sizeof_::value)) / CHAR_BIT; } static SPROUT_CONSTEXPR std::size_t whichbit(std::size_t pos) SPROUT_NOEXCEPT { - return pos % (CHAR_BIT * sprout::detail::size_t_::value); + return pos % (CHAR_BIT * sprout::detail::sizeof_::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(0) - ? i * (CHAR_BIT * sprout::detail::size_t_::value) + sprout::ctz(*first) + ? i * (CHAR_BIT * sprout::detail::sizeof_::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(0) - ? i * (CHAR_BIT * sprout::detail::size_t_::value) + sprout::ctz(*first) + ? i * (CHAR_BIT * sprout::detail::sizeof_::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(0) - ? i * (CHAR_BIT * sprout::detail::size_t_::value) + sprout::ctz(thisword) + ? i * (CHAR_BIT * sprout::detail::sizeof_::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_::value) - offset, + wshift, offset, (CHAR_BIT * sprout::detail::sizeof_::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_::value) - offset, + wshift, offset, limit, (CHAR_BIT * sprout::detail::sizeof_::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_::value))} + : w_{word_type(val), word_type(val >> (CHAR_BIT * sprout::detail::sizeof_::value))} {} template 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_::value); - std::size_t const offset = shift % (CHAR_BIT * sprout::detail::size_t_::value); + std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::sizeof_::value); + std::size_t const offset = shift % (CHAR_BIT * sprout::detail::sizeof_::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_::value) - offset; + std::size_t const sub_offset = (CHAR_BIT * sprout::detail::sizeof_::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 do_left_shift(std::size_t shift) const SPROUT_NOEXCEPT { return shift != 0 ? do_left_shift_impl( - shift / (CHAR_BIT * sprout::detail::size_t_::value), - shift % (CHAR_BIT * sprout::detail::size_t_::value) + shift / (CHAR_BIT * sprout::detail::sizeof_::value), + shift % (CHAR_BIT * sprout::detail::sizeof_::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_::value); - std::size_t const offset = shift % (CHAR_BIT * sprout::detail::size_t_::value); + std::size_t const wshift = shift / (CHAR_BIT * sprout::detail::sizeof_::value); + std::size_t const offset = shift % (CHAR_BIT * sprout::detail::sizeof_::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_::value) - offset; + std::size_t const sub_offset = (CHAR_BIT * sprout::detail::sizeof_::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 do_right_shift(std::size_t shift) const SPROUT_NOEXCEPT { return shift != 0 ? do_right_shift_impl( - shift / (CHAR_BIT * sprout::detail::size_t_::value), - shift % (CHAR_BIT * sprout::detail::size_t_::value), - N - shift / (CHAR_BIT * sprout::detail::size_t_::value) - 1 + shift / (CHAR_BIT * sprout::detail::sizeof_::value), + shift % (CHAR_BIT * sprout::detail::sizeof_::value), + N - shift / (CHAR_BIT * sprout::detail::sizeof_::value) - 1 ) : *this ; @@ -385,7 +385,7 @@ namespace sprout { } void do_reset() SPROUT_NOEXCEPT { - std::memset(w_, 0, N * sprout::detail::size_t_::value); + std::memset(w_, 0, N * sprout::detail::sizeof_::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(0) >> (N * (CHAR_BIT * sprout::detail::size_t_::value) - N2)) + && hiword() == (~static_cast(0) >> (N * (CHAR_BIT * sprout::detail::sizeof_::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_::value > sprout::detail::size_t_::value ? begin() + 2 + sprout::detail::sizeof_::value > sprout::detail::sizeof_::value ? begin() + 2 : begin() + 1 , end(), to_ulong_pred() ) != end() ? throw std::overflow_error("base_bitset::to_ullong") - : sprout::detail::size_t_::value > sprout::detail::size_t_::value + : sprout::detail::sizeof_::value > sprout::detail::sizeof_::value ? w_[0] + (static_cast(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_::value) ? not_found + return prev + 1 >= N * (CHAR_BIT * sprout::detail::sizeof_::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_::value); + return pos / (CHAR_BIT * sprout::detail::sizeof_::value); } static SPROUT_CONSTEXPR std::size_t whichbyte(std::size_t pos) SPROUT_NOEXCEPT { - return (pos % (CHAR_BIT * sprout::detail::size_t_::value)) / CHAR_BIT; + return (pos % (CHAR_BIT * sprout::detail::sizeof_::value)) / CHAR_BIT; } static SPROUT_CONSTEXPR std::size_t whichbit(std::size_t pos) SPROUT_NOEXCEPT { - return pos % (CHAR_BIT * sprout::detail::size_t_::value); + return pos % (CHAR_BIT * sprout::detail::sizeof_::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(CHAR_BIT * sprout::detail::size_t_::value) ? not_found + return prev + 1 >= static_cast(CHAR_BIT * sprout::detail::sizeof_::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_::value); + return pos / (CHAR_BIT * sprout::detail::sizeof_::value); } static SPROUT_CONSTEXPR std::size_t whichbyte(std::size_t pos) SPROUT_NOEXCEPT { - return (pos % (CHAR_BIT * sprout::detail::size_t_::value)) / CHAR_BIT; + return (pos % (CHAR_BIT * sprout::detail::sizeof_::value)) / CHAR_BIT; } static SPROUT_CONSTEXPR std::size_t whichbit(std::size_t pos) SPROUT_NOEXCEPT { - return pos % (CHAR_BIT * sprout::detail::size_t_::value); + return pos % (CHAR_BIT * sprout::detail::sizeof_::value); } static SPROUT_CONSTEXPR word_type @@ -821,7 +821,7 @@ namespace sprout { } }; - template::value))> + template::value))> struct sanitize_val { public: static SPROUT_CONSTEXPR unsigned long long @@ -892,12 +892,12 @@ namespace sprout { template class bitset : private sprout::detail::base_bitset< - N / (CHAR_BIT * sprout::detail::size_t_::value) + (N % (CHAR_BIT * sprout::detail::size_t_::value) == 0 ? 0 : 1) + N / (CHAR_BIT * sprout::detail::sizeof_::value) + (N % (CHAR_BIT * sprout::detail::sizeof_::value) == 0 ? 0 : 1) > { private: typedef sprout::detail::base_bitset< - N / (CHAR_BIT * sprout::detail::size_t_::value) + (N % (CHAR_BIT * sprout::detail::size_t_::value) == 0 ? 0 : 1) + N / (CHAR_BIT * sprout::detail::sizeof_::value) + (N % (CHAR_BIT * sprout::detail::sizeof_::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::value)> sanitize_type; + typedef sprout::detail::sanitize::value)> sanitize_type; sanitize_type::do_sanitize(this->hiword()); } SPROUT_CONSTEXPR bitset do_sanitize() const SPROUT_NOEXCEPT { - typedef sprout::detail::sanitize::value)> sanitize_type; + typedef sprout::detail::sanitize::value)> sanitize_type; return bitset(this->hiword(sanitize_type::do_sanitize_c(this->hiword()))); } SPROUT_CONSTEXPR bitset diff --git a/sprout/container/deep_internal.hpp b/sprout/container/deep_internal.hpp index 4a53f7a5..67dc7f76 100644 --- a/sprout/container/deep_internal.hpp +++ b/sprout/container/deep_internal.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace sprout { namespace containers { @@ -18,10 +19,9 @@ namespace sprout { struct deep_internal_impl< Container, Prev, typename std::enable_if::value>::type - > { - public: - typedef Container type; - }; + > + : public sprout::identity + {}; } // namespace detail // // deep_internal diff --git a/sprout/iterator/type_traits/common.hpp b/sprout/iterator/type_traits/common.hpp index 8e66e5dd..38d1e3b0 100644 --- a/sprout/iterator/type_traits/common.hpp +++ b/sprout/iterator/type_traits/common.hpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include namespace sprout { namespace detail { @@ -53,7 +55,7 @@ namespace sprout { struct min_iterator_category; template struct min_iterator_category - : public std::common_type + : public sprout::identity {}; template struct min_iterator_category @@ -106,10 +108,10 @@ namespace sprout { ) , T, - typename std::decay::type, typename std::decay::type>::type>::type + typename sprout::common_decay::type, typename std::decay::type>::type >::type >::type, - typename std::decay::type, typename std::decay::type>::type>::type + typename sprout::common_decay::type, typename std::decay::type>::type > {}; template @@ -155,9 +157,7 @@ namespace sprout { // template struct common_iterator_difference_type - : public std::decay< - typename std::common_type::difference_type...>::type - > + : public sprout::common_decay::difference_type...> {}; } // namespace sprout diff --git a/sprout/range/adaptor/steps.hpp b/sprout/range/adaptor/steps.hpp index c8516f71..ffb1fbce 100644 --- a/sprout/range/adaptor/steps.hpp +++ b/sprout/range/adaptor/steps.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT namespace sprout { @@ -91,7 +92,7 @@ namespace sprout { } template SPROUT_CONSTEXPR sprout::adaptors::step_holder - operator()(Difference width, typename std::common_type::type init) const { + operator()(Difference width, typename sprout::identity::type init) const { return sprout::adaptors::step_holder(width, init); } }; diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index a0bf0855..79409df4 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/sprout/type_traits/arithmetic_promote.hpp b/sprout/type_traits/arithmetic_promote.hpp index 154f1f17..7bbbd2e8 100644 --- a/sprout/type_traits/arithmetic_promote.hpp +++ b/sprout/type_traits/arithmetic_promote.hpp @@ -4,12 +4,13 @@ #include #include #include +#include namespace sprout { namespace detail { template struct arithmetic_promote1 - : public std::common_type + : public sprout::identity { static_assert( std::is_arithmetic::value, diff --git a/sprout/type_traits/float_promote.hpp b/sprout/type_traits/float_promote.hpp index 1c3dcedb..ca1c5735 100644 --- a/sprout/type_traits/float_promote.hpp +++ b/sprout/type_traits/float_promote.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace sprout { namespace detail { @@ -10,8 +11,8 @@ namespace sprout { struct float_promote1 : public std::conditional< std::is_floating_point::value, - std::common_type, - std::common_type + sprout::identity, + sprout::identity >::type { static_assert( @@ -24,7 +25,7 @@ namespace sprout { struct float_promote2 : public std::conditional< (std::is_same::value || std::is_same::value), - std::common_type, + sprout::identity, typename std::conditional< (std::is_same::value && std::is_same::value), float, diff --git a/sprout/type_traits/identity.hpp b/sprout/type_traits/identity.hpp new file mode 100644 index 00000000..1f1a6210 --- /dev/null +++ b/sprout/type_traits/identity.hpp @@ -0,0 +1,17 @@ +#ifndef SPROUT_TYPE_TRAITS_IDENTITY_HPP +#define SPROUT_TYPE_TRAITS_IDENTITY_HPP + +#include + +namespace sprout { + // + // identity + // + template + struct identity { + public: + typedef T type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IDENTITY_HPP diff --git a/sprout/variant/variant.hpp b/sprout/variant/variant.hpp index 12b5e808..2b2a9291 100644 --- a/sprout/variant/variant.hpp +++ b/sprout/variant/variant.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -89,10 +90,8 @@ namespace sprout { template struct visitor_result_impl_1 > { public: - typedef typename std::decay< - typename std::common_type< - decltype((std::declval())(sprout::tuples::get(std::declval())))... - >::type + typedef typename sprout::common_decay< + decltype((std::declval())(sprout::tuples::get(std::declval())))... >::type type; }; template