mirror of
https://github.com/boostorg/tti.git
synced 2026-07-21 13:33:33 +00:00
Support for static data in unrestricted unions.
This commit is contained in:
@@ -7,14 +7,17 @@
|
||||
#if !defined(BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP)
|
||||
#define BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/function_types/is_function.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/detail/yes_no_type.hpp>
|
||||
#include <boost/tti/detail/denclosing_type.hpp>
|
||||
#include <boost/tti/detail/dmacro_sunfix.hpp>
|
||||
#include <boost/tti/detail/dnullptr.hpp>
|
||||
#include <boost/tti/gen/namespace_gen.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
|
||||
@@ -81,6 +84,8 @@
|
||||
|
||||
#endif // defined(BOOST_MSVC)
|
||||
|
||||
#if defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
#define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
|
||||
BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
|
||||
template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
|
||||
@@ -95,4 +100,22 @@
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
|
||||
BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
|
||||
template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
|
||||
struct BOOST_PP_CAT(trait,_detail_hsd) : \
|
||||
boost::mpl::eval_if \
|
||||
< \
|
||||
BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \
|
||||
BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \
|
||||
boost::mpl::false_ \
|
||||
> \
|
||||
{ \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP
|
||||
|
||||
@@ -25,6 +25,13 @@ int main()
|
||||
BOOST_TEST((DAOther<AnotherType,AType>::value));
|
||||
BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>::value));
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(USMember)<AType::AnUnion,float>::value));
|
||||
BOOST_TEST((SomeUStaticD<AnotherType::AnotherUnion,char>::value));
|
||||
|
||||
#endif
|
||||
|
||||
// Passing non-class enclosing type will return false
|
||||
|
||||
BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(IntBT)<unsigned long,AType::BType>::value));
|
||||
|
||||
@@ -22,5 +22,7 @@ BOOST_TTI_HAS_DATA(IntBT)
|
||||
BOOST_TTI_TRAIT_HAS_DATA(DNestedData,NestedCT)
|
||||
BOOST_TTI_TRAIT_HAS_DATA(DAOther,OtherAT)
|
||||
BOOST_TTI_HAS_DATA(ONestStr)
|
||||
BOOST_TTI_HAS_DATA(USMember)
|
||||
BOOST_TTI_TRAIT_HAS_DATA(SomeUStaticD,ASCData)
|
||||
|
||||
#endif // TEST_HAS_DATA_HPP
|
||||
|
||||
@@ -31,6 +31,14 @@ int main()
|
||||
BOOST_MPL_ASSERT((DAOther<AnotherType,AType>));
|
||||
BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>));
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(USMember)<AType::AnUnion,float>));
|
||||
BOOST_MPL_ASSERT((SomeUStaticD<AnotherType::AnotherUnion,char>));
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@ int main()
|
||||
BOOST_TEST((StatName<AnotherType,AType::AStructType>::value));
|
||||
BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(CIntValue)<AnotherType,const int>::value));
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
BOOST_TEST((UnionStatic<AType::AnUnion,float>::value));
|
||||
BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(ASCData)<AnotherType::AnotherUnion,char>::value));
|
||||
|
||||
#endif
|
||||
|
||||
// Passing non-class enclosing type will return false
|
||||
|
||||
BOOST_TEST((!BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<unsigned short,short>::value));
|
||||
|
||||
@@ -14,5 +14,7 @@ BOOST_TTI_HAS_STATIC_MEMBER_DATA(DSMember)
|
||||
BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(StatName,AnStat)
|
||||
BOOST_TTI_HAS_STATIC_MEMBER_DATA(SomeStaticData)
|
||||
BOOST_TTI_HAS_STATIC_MEMBER_DATA(CIntValue)
|
||||
BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(UnionStatic,USMember)
|
||||
BOOST_TTI_HAS_STATIC_MEMBER_DATA(ASCData)
|
||||
|
||||
#endif // TEST_HAS_STATIC_MEMBER_DATA_HPP
|
||||
|
||||
@@ -19,6 +19,13 @@ int main()
|
||||
BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<AType,short>));
|
||||
BOOST_MPL_ASSERT((StatName<AnotherType,AType::AStructType>));
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
BOOST_MPL_ASSERT((UnionStatic<AType::AnUnion,float>));
|
||||
BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(ASCData)<AnotherType::AnotherUnion,char>));
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
+22
-1
@@ -77,8 +77,15 @@ struct AType
|
||||
UEnumV2
|
||||
};
|
||||
template <int,class,long> struct NestedMemberTemplate { };
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
static float USMember;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// Template
|
||||
|
||||
template <class> struct ATPMemberTemplate { };
|
||||
@@ -185,6 +192,13 @@ struct AnotherType
|
||||
int i;
|
||||
char ch;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
static char ASCData;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// Template
|
||||
@@ -253,4 +267,11 @@ struct MarkerType
|
||||
short AType::DSMember(5622);
|
||||
AType::AStructType AnotherType::AnStat;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
|
||||
|
||||
float AType::AnUnion::USMember(893.53);
|
||||
char AnotherType::AnotherUnion::ASCData('e');
|
||||
|
||||
#endif
|
||||
|
||||
#endif // TEST_STRUCTS_HPP
|
||||
|
||||
Reference in New Issue
Block a user