diff --git a/sprout/type_traits/is_destructible.hpp b/sprout/type_traits/is_destructible.hpp new file mode 100644 index 00000000..74f154dc --- /dev/null +++ b/sprout/type_traits/is_destructible.hpp @@ -0,0 +1,118 @@ +/*============================================================================= + Copyright (c) 2011-2015 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_DESTRUCTIBLE_HPP +#define SPROUT_TYPE_TRAITS_IS_DESTRUCTIBLE_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // is_destructible + // + namespace detail { + struct is_destructible_helper_1 { + public: + template + struct w { + U u; + }; + template< + typename T, + typename = decltype(std::declval&>().~w()) + > + static sprout::true_type test(int); + template + static sprout::false_type test(...); + }; +#if defined(_MSC_VER) + template(0))>::type> + struct is_destructible_impl_1 + : public Base_ + {}; +#else + template + struct is_destructible_impl_1 + : public sprout::identity(0))>::type + {}; +#endif + + struct is_destructible_helper_2 { + public: + template< + typename T, + typename = decltype(std::declval().~T()) + > + static sprout::true_type test(int); + template + static sprout::false_type test(...); + }; +#if defined(_MSC_VER) + template(0))>::type> + struct is_destructible_impl_2 + : public Base_ + {}; +#else + template + struct is_destructible_impl_2 + : public sprout::identity(0))>::type + {}; +#endif + + struct is_destructible_helper { + public: + template< + typename T, + typename = decltype(std::declval().~T()) + > + static sprout::true_type test(int); + template + static sprout::false_type test(...); + }; +#if defined(_MSC_VER) + template(0))>::type> + struct is_destructible_impl_0 + : public Base_ + {}; +#else + template + struct is_destructible_impl_0 + : public sprout::identity(0))>::type + {}; +#endif + + template< + typename T, + bool = std::is_void::value || (std::is_array::value && !std::extent::value), + bool = std::is_reference::value || std::is_function::value + > + struct is_destructible_impl; + template + struct is_destructible_impl + : public sprout::detail::is_destructible_impl_0::type> + {}; + template + struct is_destructible_impl + : public sprout::false_type + {}; + template + struct is_destructible_impl + : public sprout::true_type + {}; + } // namespace detail + template + struct is_destructible + : public sprout::detail::is_destructible_impl + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_DESTRUCTIBLE_HPP diff --git a/sprout/type_traits/std_type_traits.hpp b/sprout/type_traits/std_type_traits.hpp index 21822137..91887f03 100644 --- a/sprout/type_traits/std_type_traits.hpp +++ b/sprout/type_traits/std_type_traits.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #if !defined(_LIBCPP_VERSION) || (_LIBCPP_VERSION < 1101) # include @@ -195,10 +196,10 @@ namespace sprout { struct is_move_assignable : public sprout::detail::type_traits_wrapper > {}; - template - struct is_destructible - : public sprout::detail::type_traits_wrapper > - {}; +// template +// struct is_destructible +// : public sprout::detail::type_traits_wrapper > +// {}; #if !defined(_LIBCPP_VERSION) #if SPROUT_CLANG_HAS_FUTURE(is_trivially_constructible) template