diff --git a/sprout/cstdlib/abs.hpp b/sprout/cstdlib/abs.hpp index a40cf775..e164bf2a 100644 --- a/sprout/cstdlib/abs.hpp +++ b/sprout/cstdlib/abs.hpp @@ -29,24 +29,26 @@ namespace sprout { return sprout::llabs(j); } - template< - typename IntType, - typename sprout::enabler_if< - std::is_integral::value && std::is_signed::value - >::type = sprout::enabler - > - SPROUT_CONSTEXPR IntType abs(IntType j) { - return j < 0 ? -j : j; - } - template< - typename IntType, - typename sprout::enabler_if< - std::is_integral::value && std::is_unsigned::value - >::type = sprout::enabler - > - SPROUT_CONSTEXPR IntType abs(IntType j) { - return j; - } + namespace { + template< + typename IntType, + typename sprout::enabler_if< + std::is_integral::value && std::is_signed::value + >::type = sprout::enabler + > + SPROUT_CONSTEXPR IntType abs(IntType j) { + return j < 0 ? -j : j; + } + template< + typename IntType, + typename sprout::enabler_if< + std::is_integral::value && std::is_unsigned::value + >::type = sprout::enabler + > + SPROUT_CONSTEXPR IntType abs(IntType j) { + return j; + } + } // anonymous-namespace } // namespace sprout #endif // #ifndef SPROUT_CSTDLIB_ABS_HPP diff --git a/sprout/string/alias.hpp b/sprout/string/alias.hpp index d9fd74e4..9344530d 100644 --- a/sprout/string/alias.hpp +++ b/sprout/string/alias.hpp @@ -2,7 +2,6 @@ #define SPROUT_STRING_ALIAS_HPP #include - #if SPROUT_USE_TEMPLATE_ALIASES # include # include diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index 621e9d11..c3f54d4e 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -8,6 +8,9 @@ #include #include #include +#include #include +#include +#include #endif // #ifndef SPROUT_TYPE_TRAITS_HPP diff --git a/sprout/type_traits/aliases.hpp b/sprout/type_traits/aliases.hpp new file mode 100644 index 00000000..9e1384d0 --- /dev/null +++ b/sprout/type_traits/aliases.hpp @@ -0,0 +1,91 @@ +#ifndef SPROUT_TYPE_TRAITS_ALIASES_HPP +#define SPROUT_TYPE_TRAITS_ALIASES_HPP + +#include + +#if SPROUT_USE_TEMPLATE_ALIASES +# include +# include +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +namespace sprout { +#if SPROUT_USE_TEMPLATE_ALIASES + // Copyright (c) 2011 osyo-manga : http://d.hatena.ne.jp/osyo-manga/ + + // + // Const-volatility specifiers + // + template + using remove_const_ = typename std::remove_const::type; + template + using remove_volatile_ = typename std::remove_volatile::type; + template + using remove_cv_ = typename std::remove_cv::type; + template + using add_const_ = typename std::add_const::type; + template + using add_volatile_ = typename std::add_volatile::type; + template + using add_cv_ = typename std::add_cv::type; + + // + // References + // + template + using remove_reference_ = typename std::remove_reference::type; + template + using add_lvalue_reference_ = typename std::add_lvalue_reference::type; + template + using add_rvalue_reference_ = typename std::add_rvalue_reference::type; + + // + // Pointers + // + template + using remove_pointer_ = typename std::remove_pointer::type; + template + using add_pointer_ = typename std::add_pointer::type; + + // + // Sign modifiers + // + template + using make_signed_ = typename std::make_signed::type; + template + using make_unsigned_ = typename std::make_unsigned::type; + + // + // Arrays + // + template + using remove_extent_ = typename std::remove_extent::type; + template + using remove_all_extents_ = typename std::remove_all_extents::type; + + // + // Miscellaneous transformations + // + template< + std::size_t Len, + std::size_t Align = std::alignment_of::type>::value + > + using aligned_storage_ = typename std::aligned_storage::type; + // !!! + //template + //using aligned_union_ = typename std::aligned_union::type; + template + using decay_ = typename std::decay::type; + template + using enable_if_ = typename std::enable_if::type; + template + using conditional_ = typename std::conditional::type; + template + using common_type_ = typename std::common_type::type; + template + using underlying_type_ = typename std::underlying_type::type; + template + using result_of_ = typename std::result_of::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_ALIASES_HPP diff --git a/sprout/type_traits/const_reference.hpp b/sprout/type_traits/const_reference.hpp index ecb17aa5..04f5db58 100644 --- a/sprout/type_traits/const_reference.hpp +++ b/sprout/type_traits/const_reference.hpp @@ -14,6 +14,11 @@ namespace sprout { public: typedef decltype(sprout::as_const(std::declval())) type; }; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using const_reference_ = typename sprout::const_reference::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout #endif // #ifndef SPROUT_TYPE_TRAITS_CONST_REFERENCE_HPP diff --git a/sprout/type_traits/enabler_if.hpp b/sprout/type_traits/enabler_if.hpp new file mode 100644 index 00000000..a2b388c3 --- /dev/null +++ b/sprout/type_traits/enabler_if.hpp @@ -0,0 +1,28 @@ +#ifndef SPROUT_TYPE_TRAITS_ENABLER_IF_HPP +#define SPROUT_TYPE_TRAITS_ENABLER_IF_HPP + +#include +#include + +namespace sprout { + // + // enabler_t + // enabler + // + typedef void* enabler_t; + extern enabler_t enabler; + // + // enabler_if + // + template + class enabler_if + : public std::enable_if + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using enabler_if_ = typename sprout::enabler_if::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_ENABLER_IF_HPP diff --git a/sprout/type_traits/lvalue_reference.hpp b/sprout/type_traits/lvalue_reference.hpp index 7a0b1c62..40e879df 100644 --- a/sprout/type_traits/lvalue_reference.hpp +++ b/sprout/type_traits/lvalue_reference.hpp @@ -14,6 +14,11 @@ namespace sprout { public: typedef decltype(sprout::as_lvalue(std::declval())) type; }; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using lvalue_reference_ = typename sprout::lvalue_reference::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout #endif // #ifndef SPROUT_TYPE_TRAITS_LVALUE_REFERENCE_HPP diff --git a/sprout/utility/enabler_if.hpp b/sprout/utility/enabler_if.hpp index db0e4580..6525bf32 100644 --- a/sprout/utility/enabler_if.hpp +++ b/sprout/utility/enabler_if.hpp @@ -1,23 +1,7 @@ #ifndef SPROUT_UTILITY_ENABLER_IF_HPP #define SPROUT_UTILITY_ENABLER_IF_HPP -#include #include - -namespace sprout { - // - // enabler_t - // enabler - // - typedef void* enabler_t; - extern enabler_t enabler; - // - // enabler_if - // - template - class enabler_if - : public std::enable_if - {}; -} // namespace sprout +#include #endif // #ifndef SPROUT_UTILITY_ENABLER_IF_HPP