From 669f083f33e3435b8e1540305e2bb2d680ab3a98 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 18 Jan 2020 03:35:19 -0500 Subject: [PATCH 1/2] 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)); From fa90de2a36615e4a66dabdbd6682a2f9bc194353 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 18 Jan 2020 11:40:22 -0500 Subject: [PATCH 2/2] Added documentation for the new metafunctions has_property_tag and its individual equivalents. --- doc/function_types.qbk | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/function_types.qbk b/doc/function_types.qbk index 598a7b5..f41cd7a 100644 --- a/doc/function_types.qbk +++ b/doc/function_types.qbk @@ -837,6 +837,43 @@ values for the same property the value of the rightmost argument is used. [endsect] +[section:has_property_tag has_property_tag] + + template + struct has_property_tag; + +[*Header] + + #include + +[variablelist + [[[^Tag]][Possibly compound property tag]] + [[[^PropertyTag]][Single property tag]] + [[[^has_property_tag]][Test (possibly) compound property tag for single property tag]] +] + +A metafunction for testing that a compound property tag has a particular single +property tag in its composition. Returns a boolean value of true if the particular single +property tag is part of the compound property tag, otherwise false. + +For convenience there are also individual metafunctions for the built-in property tags of the form + + template + struct has_'name'_property_tag; + +which works exactly the same as `has_property_tag`, where name can be +[^variadic],[^default_cc],[^const],[^volatile],[^cv],or [^null]. +In these individual metafunctions [^const] is short for [^const_qualified], +[^volatile] is short for [^volatile_qualified], +[^cv] is short for [^cv_qualified], and [^null] is short for [^null_tag]. + +[note Testing for the [^null_tag], with either `has_property_tag` +or `has_null_property_tag`, always tests whether the [^Tag] is the single +[^null_tag] property_tag. +] + +[endsect] + [endsect] [/ Tag Types] [/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ]