From 669f083f33e3435b8e1540305e2bb2d680ab3a98 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 18 Jan 2020 03:35:19 -0500 Subject: [PATCH] Added functionality and tests that allow a possibly compound property tag to be queried to see if a given property tag is in it. This is useful if the end-user needs to know if, let's say, a const property has been set in the property tag. Since a property tag may be a compound property tag consisting of more than one property tag it is not possible to determine such a thing by just using boost::is_same to see if the two are equal. --- .../boost/function_types/property_tags.hpp | 52 +++++++++++++++ test/Jamfile | 4 ++ test/custom_ccs/property_tag.cpp | 64 +++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 test/custom_ccs/property_tag.cpp diff --git a/include/boost/function_types/property_tags.hpp b/include/boost/function_types/property_tags.hpp index c2158d3..3760a8b 100644 --- a/include/boost/function_types/property_tags.hpp +++ b/include/boost/function_types/property_tags.hpp @@ -12,6 +12,7 @@ #include #include +#include #include @@ -134,6 +135,20 @@ template struct extract > mask; }; +/* + + The following is a metafunction which checks whether a + property tag is in a possibly compounded tag type. + + Here both the possibly compounded tag type and a property tag + is given. + +*/ + +template struct has_property_tag + : detail::represents_impl +{ }; + } } // namespace ::boost::function_types #include @@ -141,6 +156,43 @@ template struct extract namespace boost { namespace function_types { #define BOOST_FT_cc_file #include + +/* + + The following are metafunctions which check whether the + specific property tag is in a possibly compounded tag type. + Here only the possibly compounded tag type is given. + +*/ + +template struct has_property_tag + : ::boost::is_same +{ }; + +template struct has_variadic_property_tag + : has_property_tag +{ }; + +template struct has_default_cc_property_tag + : has_property_tag +{ }; + +template struct has_const_property_tag + : has_property_tag +{ }; + +template struct has_volatile_property_tag + : has_property_tag +{ }; + +template struct has_cv_property_tag + : has_property_tag +{ }; + +template struct has_null_property_tag + : has_property_tag +{ }; + } } // namespace boost::function_types #endif diff --git a/test/Jamfile b/test/Jamfile index e50c813..e652c46 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -69,6 +69,10 @@ import testing ; [ compile custom_ccs/member_ccs.cpp : 64:no ] [ compile custom_ccs/member_ccs_exact.cpp : 64:no ] + # Property tag + + [ compile custom_ccs/property_tag.cpp ] + # Code from the examples [ compile ../example/interpreter_example.cpp ] diff --git a/test/custom_ccs/property_tag.cpp b/test/custom_ccs/property_tag.cpp new file mode 100644 index 0000000..00d2419 --- /dev/null +++ b/test/custom_ccs/property_tag.cpp @@ -0,0 +1,64 @@ + +// (C) Copyright Edward Diener 2019 +// Use, modification and distribution are subject to 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). + +//------------------------------------------------------------------------------ + +#include +#include + +namespace ft = boost::function_types; +namespace mpl = boost::mpl; + +typedef ft::tag tag1; +typedef ft::tag tag2; +typedef ft::tag tag3; +typedef ft::null_tag tag4; +typedef ft::tag tag5; +typedef ft::tag tag6; +typedef ft::tag tag7; +typedef ft::tag tag8; + +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); +BOOST_MPL_ASSERT((ft::has_property_tag)); + +BOOST_MPL_ASSERT((ft::has_variadic_property_tag)); +BOOST_MPL_ASSERT((ft::has_variadic_property_tag)); +BOOST_MPL_ASSERT((ft::has_variadic_property_tag)); +BOOST_MPL_ASSERT((ft::has_variadic_property_tag)); +BOOST_MPL_ASSERT((ft::has_default_cc_property_tag)); +BOOST_MPL_ASSERT((ft::has_default_cc_property_tag)); +BOOST_MPL_ASSERT((ft::has_default_cc_property_tag)); +BOOST_MPL_ASSERT((ft::has_const_property_tag)); +BOOST_MPL_ASSERT((ft::has_const_property_tag)); +BOOST_MPL_ASSERT((ft::has_const_property_tag)); +BOOST_MPL_ASSERT((ft::has_volatile_property_tag)); +BOOST_MPL_ASSERT((ft::has_volatile_property_tag)); +BOOST_MPL_ASSERT((ft::has_volatile_property_tag)); +BOOST_MPL_ASSERT((ft::has_cv_property_tag)); +BOOST_MPL_ASSERT((ft::has_null_property_tag)); + +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_property_tag)); + +BOOST_MPL_ASSERT_NOT((ft::has_variadic_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_default_cc_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_const_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_const_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_volatile_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_cv_property_tag)); +BOOST_MPL_ASSERT_NOT((ft::has_null_property_tag));