File indexing completed on 2025-01-18 09:53:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_TT_IS_EMPTY_HPP_INCLUDED
0010 #define BOOST_TT_IS_EMPTY_HPP_INCLUDED
0011
0012 #include <boost/type_traits/is_convertible.hpp>
0013 #include <boost/type_traits/detail/config.hpp>
0014 #include <boost/type_traits/intrinsics.hpp>
0015
0016 #include <boost/type_traits/remove_cv.hpp>
0017 #include <boost/type_traits/is_class.hpp>
0018 #include <boost/type_traits/add_reference.hpp>
0019
0020 #ifndef BOOST_INTERNAL_IS_EMPTY
0021 #define BOOST_INTERNAL_IS_EMPTY(T) false
0022 #else
0023 #define BOOST_INTERNAL_IS_EMPTY(T) BOOST_IS_EMPTY(T)
0024 #endif
0025
0026 namespace boost {
0027
0028 namespace detail {
0029
0030
0031 #ifdef BOOST_MSVC
0032 #pragma warning(push)
0033 #pragma warning(disable:4624)
0034 #endif
0035
0036 template <typename T>
0037 struct empty_helper_t1 : public T
0038 {
0039 empty_helper_t1();
0040 int i[256];
0041 private:
0042
0043 empty_helper_t1(const empty_helper_t1&);
0044 empty_helper_t1& operator=(const empty_helper_t1&);
0045 };
0046
0047 #ifdef BOOST_MSVC
0048 #pragma warning(pop)
0049 #endif
0050
0051 struct empty_helper_t2 { int i[256]; };
0052
0053 #if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
0054
0055 template <typename T, bool is_a_class = false>
0056 struct empty_helper
0057 {
0058 BOOST_STATIC_CONSTANT(bool, value = false);
0059 };
0060
0061 template <typename T>
0062 struct empty_helper<T, true>
0063 {
0064 BOOST_STATIC_CONSTANT(
0065 bool, value = (sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2))
0066 );
0067 };
0068
0069 template <typename T>
0070 struct is_empty_impl
0071 {
0072 typedef typename remove_cv<T>::type cvt;
0073 BOOST_STATIC_CONSTANT(
0074 bool,
0075 value = ( ::boost::detail::empty_helper<cvt,::boost::is_class<T>::value>::value || BOOST_INTERNAL_IS_EMPTY(cvt)));
0076 };
0077
0078 #else
0079
0080 template <typename T, bool is_a_class, bool convertible_to_int>
0081 struct empty_helper
0082 {
0083 BOOST_STATIC_CONSTANT(bool, value = false);
0084 };
0085
0086 template <typename T>
0087 struct empty_helper<T, true, false>
0088 {
0089 BOOST_STATIC_CONSTANT(bool, value = (
0090 sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2)
0091 ));
0092 };
0093
0094 template <typename T>
0095 struct is_empty_impl
0096 {
0097 typedef typename remove_cv<T>::type cvt;
0098 typedef typename add_reference<T>::type r_type;
0099
0100 BOOST_STATIC_CONSTANT(
0101 bool, value = (
0102 ::boost::detail::empty_helper<
0103 cvt
0104 , ::boost::is_class<T>::value
0105 , ::boost::is_convertible< r_type,int>::value
0106 >::value || BOOST_INTERNAL_IS_EMPTY(cvt)));
0107 };
0108
0109 #endif
0110
0111 }
0112
0113 template <class T> struct is_empty : integral_constant<bool, ::boost::detail::is_empty_impl<T>::value> {};
0114
0115 }
0116
0117 #undef BOOST_INTERNAL_IS_EMPTY
0118
0119 #endif
0120