concept_check_test.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // (C) Copyright Jeremy Siek 2000.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/concept_check.hpp>
  6. #include <boost/concept_archetype.hpp>
  7. /*
  8. This file verifies that function_requires() of the Boost Concept
  9. Checking Library does not cause errors when it is not suppose to
  10. and verifies that the concept archetypes meet the requirements of
  11. their matching concepts.
  12. */
  13. int
  14. main()
  15. {
  16. using namespace boost;
  17. //===========================================================================
  18. // Basic Concepts
  19. {
  20. typedef default_constructible_archetype<> foo;
  21. function_requires< DefaultConstructible<foo> >();
  22. }
  23. {
  24. typedef assignable_archetype<> foo;
  25. function_requires< Assignable<foo> >();
  26. }
  27. {
  28. typedef copy_constructible_archetype<> foo;
  29. function_requires< CopyConstructible<foo> >();
  30. }
  31. {
  32. typedef sgi_assignable_archetype<> foo;
  33. function_requires< SGIAssignable<foo> >();
  34. }
  35. {
  36. typedef copy_constructible_archetype<> foo;
  37. typedef convertible_to_archetype<foo> convertible_to_foo;
  38. function_requires< Convertible<convertible_to_foo, foo> >();
  39. }
  40. {
  41. function_requires< Convertible<boolean_archetype, bool> >();
  42. }
  43. {
  44. typedef equality_comparable_archetype<> foo;
  45. function_requires< EqualityComparable<foo> >();
  46. }
  47. {
  48. typedef less_than_comparable_archetype<> foo;
  49. function_requires< LessThanComparable<foo> >();
  50. }
  51. {
  52. typedef comparable_archetype<> foo;
  53. function_requires< Comparable<foo> >();
  54. }
  55. {
  56. typedef equal_op_first_archetype<> First;
  57. typedef equal_op_second_archetype<> Second;
  58. function_requires< EqualOp<First, Second> >();
  59. }
  60. {
  61. typedef not_equal_op_first_archetype<> First;
  62. typedef not_equal_op_second_archetype<> Second;
  63. function_requires< NotEqualOp<First, Second> >();
  64. }
  65. {
  66. typedef less_than_op_first_archetype<> First;
  67. typedef less_than_op_second_archetype<> Second;
  68. function_requires< LessThanOp<First, Second> >();
  69. }
  70. {
  71. typedef less_equal_op_first_archetype<> First;
  72. typedef less_equal_op_second_archetype<> Second;
  73. function_requires< LessEqualOp<First, Second> >();
  74. }
  75. {
  76. typedef greater_than_op_first_archetype<> First;
  77. typedef greater_than_op_second_archetype<> Second;
  78. function_requires< GreaterThanOp<First, Second> >();
  79. }
  80. {
  81. typedef greater_equal_op_first_archetype<> First;
  82. typedef greater_equal_op_second_archetype<> Second;
  83. function_requires< GreaterEqualOp<First, Second> >();
  84. }
  85. {
  86. typedef copy_constructible_archetype<> Return;
  87. typedef plus_op_first_archetype<Return> First;
  88. typedef plus_op_second_archetype<Return> Second;
  89. function_requires< PlusOp<Return, First, Second> >();
  90. }
  91. //===========================================================================
  92. // Function Object Concepts
  93. {
  94. typedef generator_archetype<null_archetype<> > foo;
  95. function_requires< Generator<foo, null_archetype<> > >();
  96. }
  97. #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  98. {
  99. function_requires< Generator< void_generator_archetype, void > >();
  100. }
  101. #endif
  102. {
  103. typedef unary_function_archetype<int, int> F;
  104. function_requires< UnaryFunction<F, int, int> >();
  105. }
  106. {
  107. typedef binary_function_archetype<int, int, int> F;
  108. function_requires< BinaryFunction<F, int, int, int> >();
  109. }
  110. {
  111. typedef unary_predicate_archetype<int> F;
  112. function_requires< UnaryPredicate<F, int> >();
  113. }
  114. {
  115. typedef binary_predicate_archetype<int, int> F;
  116. function_requires< BinaryPredicate<F, int, int> >();
  117. }
  118. //===========================================================================
  119. // Iterator Concepts
  120. {
  121. typedef input_iterator_archetype<null_archetype<> > Iter;
  122. function_requires< InputIterator<Iter> >();
  123. }
  124. {
  125. typedef output_iterator_archetype<int> Iter;
  126. function_requires< OutputIterator<Iter, int> >();
  127. }
  128. {
  129. typedef input_output_iterator_archetype<int> Iter;
  130. function_requires< InputIterator<Iter> >();
  131. function_requires< OutputIterator<Iter, int> >();
  132. }
  133. {
  134. typedef forward_iterator_archetype<null_archetype<> > Iter;
  135. function_requires< ForwardIterator<Iter> >();
  136. }
  137. {
  138. typedef mutable_forward_iterator_archetype<assignable_archetype<> > Iter;
  139. function_requires< Mutable_ForwardIterator<Iter> >();
  140. }
  141. {
  142. typedef bidirectional_iterator_archetype<null_archetype<> > Iter;
  143. function_requires< BidirectionalIterator<Iter> >();
  144. }
  145. {
  146. typedef mutable_bidirectional_iterator_archetype<assignable_archetype<> >
  147. Iter;
  148. function_requires< Mutable_BidirectionalIterator<Iter> >();
  149. }
  150. {
  151. typedef random_access_iterator_archetype<null_archetype<> > Iter;
  152. function_requires< RandomAccessIterator<Iter> >();
  153. }
  154. {
  155. typedef mutable_random_access_iterator_archetype<assignable_archetype<> >
  156. Iter;
  157. function_requires< Mutable_RandomAccessIterator<Iter> >();
  158. }
  159. //===========================================================================
  160. // Container Concepts
  161. // UNDER CONSTRUCTION
  162. return 0;
  163. }