diff --git a/sprout/container/std/complex.hpp b/sprout/container/std/complex.hpp index 174890c5..88175906 100644 --- a/sprout/container/std/complex.hpp +++ b/sprout/container/std/complex.hpp @@ -9,8 +9,8 @@ #define SPROUT_CONTAINER_STD_COMPLEX_HPP #include -#include #include +#include #include #include #include @@ -25,7 +25,7 @@ namespace sprout { operator()(Complex const& c, Index i) const { return i == 0 ? c.real() : i == 1 ? c.imag() - : throw std::out_of_range("std_complex_at<>: index out of range") + : throw std::out_of_range("std_complex_at: index out of range") ; } }; diff --git a/sprout/cstdlib/div.hpp b/sprout/cstdlib/div.hpp index df38f754..0bf02507 100644 --- a/sprout/cstdlib/div.hpp +++ b/sprout/cstdlib/div.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include namespace sprout { // @@ -348,7 +348,7 @@ namespace sprout { { return i == 0 ? d.quot : i == 1 ? d.rem - : (SPROUT_ASSERT(i < 2), d.quot) + : (throw std::out_of_range("div_at: index out of range"), d.quot) ; } template @@ -358,7 +358,7 @@ namespace sprout { { return i == 0 ? d.quot : i == 1 ? d.rem - : (SPROUT_ASSERT(i < 2), d.quot) + : (throw std::out_of_range("div_at: index out of range"), d.quot) ; } diff --git a/sprout/static_warning.hpp b/sprout/static_warning.hpp index 9871db7d..c8a82b2d 100644 --- a/sprout/static_warning.hpp +++ b/sprout/static_warning.hpp @@ -21,7 +21,7 @@ namespace sprout { template static void warn() {} }; - template <> + template<> struct static_warning { template static void warn() { diff --git a/sprout/type_traits/common_type.hpp b/sprout/type_traits/common_type.hpp index 971c3072..d8ed4396 100644 --- a/sprout/type_traits/common_type.hpp +++ b/sprout/type_traits/common_type.hpp @@ -38,7 +38,7 @@ namespace sprout { : public sprout::detail::undecayed_common_type_impl::type, Tail...> {}; } // namespace detail - template + template struct undecayed_common_type : public sprout::detail::undecayed_common_type_impl {}; @@ -58,7 +58,7 @@ namespace sprout { : public std::decay {}; } // namespace detail - template + template struct common_type : public sprout::detail::common_type_impl > {}; diff --git a/sprout/type_traits/conjunction.hpp b/sprout/type_traits/conjunction.hpp new file mode 100644 index 00000000..27955098 --- /dev/null +++ b/sprout/type_traits/conjunction.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_CONJUNCTION_HPP +#define SPROUT_TYPE_TRAITS_CONJUNCTION_HPP + +#include +#include + +namespace sprout { + // + // conjunction + // + template + struct conjunction + : public sprout::tpp::all_of + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool conjunction_v = sprout::conjunction::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_CONJUNCTION_HPP diff --git a/sprout/type_traits/disjunction.hpp b/sprout/type_traits/disjunction.hpp new file mode 100644 index 00000000..3e224c52 --- /dev/null +++ b/sprout/type_traits/disjunction.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_DISJUNCTION_HPP +#define SPROUT_TYPE_TRAITS_DISJUNCTION_HPP + +#include +#include + +namespace sprout { + // + // disjunction + // + template + struct disjunction + : public sprout::tpp::any_of + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool disjunction_v = sprout::disjunction::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_DISJUNCTION_HPP diff --git a/sprout/type_traits/enable_if_has_type.hpp b/sprout/type_traits/enable_if_has_type.hpp index 4f4e80ec..c0c6a38d 100644 --- a/sprout/type_traits/enable_if_has_type.hpp +++ b/sprout/type_traits/enable_if_has_type.hpp @@ -19,6 +19,11 @@ namespace sprout { public: typedef R type; }; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using enable_if_has_type_t = typename sprout::enable_if_has_type::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout #endif // #ifndef SPROUT_TYPE_TRAITS_ENABLE_IF_HAS_TYPE_HPP diff --git a/sprout/type_traits/is_nothrow_swappable.hpp b/sprout/type_traits/is_nothrow_swappable.hpp new file mode 100644 index 00000000..a61ca4c2 --- /dev/null +++ b/sprout/type_traits/is_nothrow_swappable.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_HPP +#define SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_HPP + +#include +#include + +namespace sprout { + // + // is_nothrow_swappable + // + template + struct is_nothrow_swappable + : public sprout::is_nothrow_swappable_with + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_nothrow_swappable_v = sprout::is_nothrow_swappable::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_HPP diff --git a/sprout/type_traits/is_nothrow_swappable_with.hpp b/sprout/type_traits/is_nothrow_swappable_with.hpp new file mode 100644 index 00000000..455ca69c --- /dev/null +++ b/sprout/type_traits/is_nothrow_swappable_with.hpp @@ -0,0 +1,53 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_WITH_HPP +#define SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_WITH_HPP + +#include +#include +#include +#include + +namespace sprout_nothrow_swappable_detail { + using std::swap; + + template + struct is_nothrow_swappable_with + : public sprout::bool_constant< + SPROUT_NOEXCEPT_EXPR(swap(std::declval(), std::declval())) + && SPROUT_NOEXCEPT_EXPR(swap(std::declval(), std::declval())) + >::type + {}; +} // namespace sprout_nothrow_swappable_detail + +namespace sprout { + namespace detail { + template + struct is_nothrow_swappable_with_impl + : public sprout::false_type + {}; + template + struct is_nothrow_swappable_with_impl + : public sprout_nothrow_swappable_detail::is_nothrow_swappable_with + {}; + } // namespace detail + // + // is_nothrow_swappable_with + // + template + struct is_nothrow_swappable_with + : public sprout::detail::is_nothrow_swappable_with_impl::value> + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_nothrow_swappable_with_v = sprout::is_nothrow_swappable_with::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_WITH_HPP diff --git a/sprout/type_traits/is_signed.hpp b/sprout/type_traits/is_signed.hpp index 57266187..57278b4a 100644 --- a/sprout/type_traits/is_signed.hpp +++ b/sprout/type_traits/is_signed.hpp @@ -27,7 +27,7 @@ namespace sprout { : public sprout::detail::type_traits_wrapper > {}; } // namespace detail - template + template struct is_signed : public sprout::detail::is_signed_impl {}; diff --git a/sprout/type_traits/is_swappable.hpp b/sprout/type_traits/is_swappable.hpp new file mode 100644 index 00000000..b36f9c1c --- /dev/null +++ b/sprout/type_traits/is_swappable.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_SWAPPABLE_HPP +#define SPROUT_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP + +#include +#include + +namespace sprout { + // + // is_swappable + // + template + struct is_swappable + : public sprout::is_swappable_with + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_swappable_v = sprout::is_swappable::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_SWAPPABLE_HPP diff --git a/sprout/type_traits/is_swappable_with.hpp b/sprout/type_traits/is_swappable_with.hpp new file mode 100644 index 00000000..f5eec324 --- /dev/null +++ b/sprout/type_traits/is_swappable_with.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP +#define SPROUT_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP + +#include +#include +#include +#include + +namespace sprout_swappable_detail { + using std::swap; + + template + struct is_swappable_with_test { + public: + template< + typename T1 = T, typename U1 = U, + typename = typename sprout::identity(), std::declval()))>::type, + typename = typename sprout::identity(), std::declval()))>::type + > + static sprout::true_type test(int); + static sprout::false_type test(...); + }; +#if defined(_MSC_VER) && (_MSC_VER > 1900) + template::test(0))>::type> + struct is_swappable_with + : public Base_ + {}; +#else + template + struct is_swappable_with + : public sprout::identity::test(0))>::type + {}; +#endif +} // namespace sprout_swappable_detail + +namespace sprout { + // + // is_swappable_with + // + template + struct is_swappable_with + : public sprout_swappable_detail::is_swappable_with + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_swappable_with_v = sprout::is_swappable_with::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP diff --git a/sprout/type_traits/is_unsigned.hpp b/sprout/type_traits/is_unsigned.hpp index 895631ff..0013e26b 100644 --- a/sprout/type_traits/is_unsigned.hpp +++ b/sprout/type_traits/is_unsigned.hpp @@ -27,7 +27,7 @@ namespace sprout { : public sprout::detail::type_traits_wrapper > {}; } // namespace detail - template + template struct is_unsigned : public sprout::detail::is_unsigned_impl {}; diff --git a/sprout/type_traits/logical.hpp b/sprout/type_traits/logical.hpp new file mode 100644 index 00000000..c3784d93 --- /dev/null +++ b/sprout/type_traits/logical.hpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_LOGICAL_HPP +#define SPROUT_TYPE_TRAITS_LOGICAL_HPP + +#include +// logical operator traits: +#include +#include +#include + +#endif // #ifndef SPROUT_TYPE_TRAITS_LOGICAL_HPP diff --git a/sprout/type_traits/negation.hpp b/sprout/type_traits/negation.hpp new file mode 100644 index 00000000..46541de3 --- /dev/null +++ b/sprout/type_traits/negation.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_NEGATION_HPP +#define SPROUT_TYPE_TRAITS_NEGATION_HPP + +#include +#include + +namespace sprout { + // + // negation + // + template + struct negation + : public sprout::bool_constant + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool negation_v = sprout::negation::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_NEGATION_HPP diff --git a/sprout/type_traits/property.hpp b/sprout/type_traits/property.hpp index a0b931bc..a002c7cf 100644 --- a/sprout/type_traits/property.hpp +++ b/sprout/type_traits/property.hpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include #include @@ -46,6 +48,8 @@ #include #include #include +#include +#include #include #include diff --git a/sprout/type_traits/std_type_traits.hpp b/sprout/type_traits/std_type_traits.hpp index af91b744..1df5bcf5 100644 --- a/sprout/type_traits/std_type_traits.hpp +++ b/sprout/type_traits/std_type_traits.hpp @@ -21,5 +21,7 @@ #include #include #include +#include +#include #endif // #ifndef SPROUT_TYPE_TRAITS_STD_TYPE_TRAITS_HPP diff --git a/sprout/type_traits/voider.hpp b/sprout/type_traits/voider.hpp new file mode 100644 index 00000000..0db420f0 --- /dev/null +++ b/sprout/type_traits/voider.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_TYPE_TRAITS_VOIDER_HPP +#define SPROUT_TYPE_TRAITS_VOIDER_HPP + +#include + +namespace sprout { + // + // voider + // + template + struct voider { + public: + typedef void type; + }; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using void_t = void; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_VOIDER_HPP