diff --git a/Jamfile b/Jamfile new file mode 100644 index 0000000..d06135e --- /dev/null +++ b/Jamfile @@ -0,0 +1,9 @@ +subproject libs/concept_check ; + +SEARCH on testing.jam = $(BOOST_BUILD_PATH) ; +include testing.jam ; + +compile concept_check_test.cpp ; +compile class_concept_check_test.cpp ; +link-fail concept_check_fail_expected.cpp ; +link-fail class_concept_fail_expected.cpp ; diff --git a/class_concept_check_test.cpp b/class_concept_check_test.cpp index b54fced..3c2c34d 100644 --- a/class_concept_check_test.cpp +++ b/class_concept_check_test.cpp @@ -8,7 +8,7 @@ /* - This file verifies that the BOOST_CLASS_REQUIRES macro of the Boost + This file verifies that the BOOST_CLASS_REQUIRE macro of the Boost Concept Checking Library does not cause errors when it is not suppose to. @@ -17,21 +17,19 @@ struct foo { bool operator()(int) { return true; } }; struct bar { bool operator()(int, char) { return true; } }; -using namespace boost; - class class_requires_test { - BOOST_CLASS_REQUIRES(int, EqualityComparableConcept); + BOOST_CLASS_REQUIRE(int, boost, EqualityComparableConcept); typedef int* int_ptr; typedef const int* const_int_ptr; - BOOST_CLASS_REQUIRES2(int_ptr, const_int_ptr, EqualOpConcept); - BOOST_CLASS_REQUIRES3(foo, bool, int, UnaryFunctionConcept); - BOOST_CLASS_REQUIRES4(bar, bool, int, char, BinaryFunctionConcept); + BOOST_CLASS_REQUIRE2(int_ptr, const_int_ptr, boost, EqualOpConcept); + BOOST_CLASS_REQUIRE3(foo, bool, int, boost, UnaryFunctionConcept); + BOOST_CLASS_REQUIRE4(bar, bool, int, char, boost, BinaryFunctionConcept); }; int main() { class_requires_test x; - ignore_unused_variable_warning(x); + boost::ignore_unused_variable_warning(x); return 0; } diff --git a/class_concept_fail_expected.cpp b/class_concept_fail_expected.cpp index 9e24471..da81108 100644 --- a/class_concept_fail_expected.cpp +++ b/class_concept_fail_expected.cpp @@ -18,11 +18,9 @@ struct foo { }; -using namespace boost; - class class_requires_test { - BOOST_CLASS_REQUIRES(foo, EqualityComparableConcept); + BOOST_CLASS_REQUIRE(foo, boost, EqualityComparableConcept); }; int diff --git a/creating_concepts.htm b/creating_concepts.htm index 3bfdd30..55fa8d7 100644 --- a/creating_concepts.htm +++ b/creating_concepts.htm @@ -42,8 +42,8 @@ RandomAccessIterator and the concepts which it builds upon: BidirectionalIterator and LessThanComparable. We could have instead used -BOOST_CLASS_REQUIRES and placed these requirements in the class -body, however BOOST_CLASS_REQUIRES uses C++ language features that +BOOST_CLASS_REQUIRE and placed these requirements in the class +body, however BOOST_CLASS_REQUIRE uses C++ language features that are less portable.

diff --git a/implementation.htm b/implementation.htm index ac75fb0..f2c7a24 100644 --- a/implementation.htm +++ b/implementation.htm @@ -129,7 +129,7 @@ everything in a do-while loop to prevent name collisions. To check the type parameters of class templates, we provide the -BOOST_CLASS_REQUIRES macro which can be used inside the body of a +BOOST_CLASS_REQUIRE macro which can be used inside the body of a class definition (whereas function_requires() can only be used inside of a function body). This macro declares a nested class template, where the template parameter is a function pointer. We then @@ -139,23 +139,22 @@ of the constraint function as the template argument. We use the typedef names to help prevent name collisions.

-#define BOOST_CLASS_REQUIRES(type_var, concept) \
-  typedef void (concept <type_var>::* func##type_var##concept)(); \
+#define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
+  typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
   template <func##type_var##concept _Tp1> \
   struct concept_checking_##type_var##concept { }; \
   typedef concept_checking_##type_var##concept< \
-    BOOST_FPTR concept <type_var>::constraints> \
+    BOOST_FPTR ns::concept<type_var>::constraints> \
     concept_checking_typedef_##type_var##concept
 
-In addition, there are versions of BOOST_CLASS_REQUIRES that +In addition, there are versions of BOOST_CLASS_REQUIRE that take more arguments, to handle concepts that include interactions -between two or more types. BOOST_CLASS_REQUIRES was not used -in the implementation of the BCCL concept checks because several +between two or more types. BOOST_CLASS_REQUIRE was not used +in the implementation of the BCCL concept checks because some compilers do not implement template parameters of function pointer type. -