2 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_IS_EMPTY_HPP_INCLUDED
10 #define BOOST_TT_IS_EMPTY_HPP_INCLUDED
12 #include <boost/type_traits/is_convertible.hpp>
13 #include <boost/type_traits/detail/config.hpp>
14 #include <boost/type_traits/intrinsics.hpp>
16 #include <boost/type_traits/remove_cv.hpp>
17 #include <boost/type_traits/is_class.hpp>
18 #include <boost/type_traits/add_reference.hpp>
20 #ifndef BOOST_INTERNAL_IS_EMPTY
21 #define BOOST_INTERNAL_IS_EMPTY(T) false
23 #define BOOST_INTERNAL_IS_EMPTY(T) BOOST_IS_EMPTY(T)
33 #pragma warning(disable:4624) // destructor could not be generated
37 struct empty_helper_t1 : public T
39 empty_helper_t1(); // hh compiler bug workaround
42 // suppress compiler warnings:
43 empty_helper_t1(const empty_helper_t1&);
44 empty_helper_t1& operator=(const empty_helper_t1&);
51 struct empty_helper_t2 { int i[256]; };
53 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
55 template <typename T, bool is_a_class = false>
58 BOOST_STATIC_CONSTANT(bool, value = false);
62 struct empty_helper<T, true>
64 BOOST_STATIC_CONSTANT(
65 bool, value = (sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2))
72 typedef typename remove_cv<T>::type cvt;
73 BOOST_STATIC_CONSTANT(
75 value = ( ::boost::detail::empty_helper<cvt,::boost::is_class<T>::value>::value || BOOST_INTERNAL_IS_EMPTY(cvt)));
80 template <typename T, bool is_a_class, bool convertible_to_int>
83 BOOST_STATIC_CONSTANT(bool, value = false);
87 struct empty_helper<T, true, false>
89 BOOST_STATIC_CONSTANT(bool, value = (
90 sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2)
97 typedef typename remove_cv<T>::type cvt;
98 typedef typename add_reference<T>::type r_type;
100 BOOST_STATIC_CONSTANT(
102 ::boost::detail::empty_helper<
104 , ::boost::is_class<T>::value
105 , ::boost::is_convertible< r_type,int>::value
106 >::value || BOOST_INTERNAL_IS_EMPTY(cvt));
109 #endif // __BORLANDC__
111 } // namespace detail
113 template <class T> struct is_empty : integral_constant<bool, ::boost::detail::is_empty_impl<T>::value> {};
117 #undef BOOST_INTERNAL_IS_EMPTY
119 #endif // BOOST_TT_IS_EMPTY_HPP_INCLUDED