Brian Silverman | bca6d25 | 2018-08-04 23:36:16 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 5 | <!-- Copyright (c) Jeremy Siek and Andrew Lumsdaine 2000 --> |
| 6 | <!-- Distributed under the Boost --> |
| 7 | <!-- Software License, Version 1.0. (See accompanying --> |
| 8 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
| 9 | |
| 10 | <head> |
| 11 | <meta name="generator" content= |
| 12 | "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" /> |
| 13 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 14 | <link rel="stylesheet" href="../../rst.css" type="text/css" /> |
| 15 | |
| 16 | <title>Boost Concept Checking Reference</title> |
| 17 | </head> |
| 18 | |
| 19 | <body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink= |
| 20 | "#FF0000"> |
| 21 | <img src="../../boost.png" alt="C++ Boost" width="277" height= |
| 22 | "86" /><br clear="none" /> |
| 23 | |
| 24 | <h2><a name="reference" id="reference">Reference</a></h2> |
| 25 | |
| 26 | <ol> |
| 27 | <li><a href="#macros">Macros</a></li> |
| 28 | |
| 29 | <li><a href="#basic-concepts">Basic Concept Checking Classes</a></li> |
| 30 | |
| 31 | <li><a href="#iterator-concepts">Iterator Concept Checking |
| 32 | Classes</a></li> |
| 33 | |
| 34 | <li><a href="#function-object-concepts">Function Object Concept Checking |
| 35 | Classes</a></li> |
| 36 | |
| 37 | <li><a href="#container-concepts">Container Concept Checking |
| 38 | Classes</a></li> |
| 39 | |
| 40 | <li><a href="#basic-archetype">Basic Archetype Classes</a></li> |
| 41 | |
| 42 | <li><a href="#iterator-archetype">Iterator Archetype Classes</a></li> |
| 43 | |
| 44 | <li><a href="#function-object-archetype">Function Object Archetype |
| 45 | Classes</a></li> |
| 46 | |
| 47 | <li><a href="#container-archetype">Container Archetype Classes</a></li> |
| 48 | |
| 49 | <li><a href="#deprecated-functions">Deprecated Functions</a></li> |
| 50 | |
| 51 | <li><a href="#deprecated-macros">Deprecated Macros</a></li> |
| 52 | |
| 53 | <li><a href="#deprecated-concept-checking-classes">Deprecated Concept |
| 54 | Checking Classes</a></li> |
| 55 | </ol> |
| 56 | |
| 57 | <h3><a name="macros" id="macros">Macros</a></h3> |
| 58 | <pre> |
| 59 | #include "boost/concept/assert.hpp" |
| 60 | |
| 61 | BOOST_CONCEPT_ASSERT((<em>concept checking class template specialization</em>)); |
| 62 | </pre> |
| 63 | |
| 64 | <p><strong>Effects:</strong> causes a compilation failure if the concept is |
| 65 | not satisfied.<br /> |
| 66 | <strong>Note:</strong> this macro can be used at global, class, or function |
| 67 | scope.</p> |
| 68 | |
| 69 | <pre> |
| 70 | #include "boost/concept/requires.hpp" |
| 71 | |
| 72 | <font color="gray">template <…<em>template parameters</em>…></font> |
| 73 | BOOST_CONCEPT_REQUIRES( |
| 74 | ((<em>concept checking class template specialization<sub>1</sub></em>)) |
| 75 | ((<em>concept checking class template specialization<sub>2</sub></em>))… |
| 76 | ((<em>concept checking class template specialization<sub>n</sub></em>))<strong>,</strong> |
| 77 | (<em>function return type</em>) |
| 78 | ) <font color="gray"><em>function_template_name</em>(…<em>function parameters</em>…)</font> |
| 79 | </pre> |
| 80 | |
| 81 | <p><strong>Effects:</strong> causes a compilation failure if the |
| 82 | given concepts are not satisfied.<br /> |
| 83 | <strong>Note:</strong> this macro is intended to be used in place of |
| 84 | a function template's return type.</p> |
| 85 | |
| 86 | <h3><a name="basic-concepts" id="basic-concepts">Basic Concept Checking |
| 87 | Classes</a></h3> |
| 88 | <pre> |
| 89 | #include "boost/concept_check.hpp" |
| 90 | |
| 91 | template <class T> |
| 92 | struct Integer; // Is T a built-in integer type? |
| 93 | |
| 94 | template <class T> |
| 95 | struct SignedInteger; // Is T a built-in signed integer type? |
| 96 | |
| 97 | template <class T> |
| 98 | struct UnsignedInteger; // Is T a built-in unsigned integer type? |
| 99 | |
| 100 | template <class X, class Y> |
| 101 | struct Convertible; // Is X convertible to Y? |
| 102 | |
| 103 | template <class T> |
| 104 | struct <a href= |
| 105 | "../utility/Assignable.html">Assignable</a>; // Standard ref 23.1 |
| 106 | |
| 107 | template <class T> |
| 108 | struct SGI<a href= |
| 109 | "http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>; |
| 110 | |
| 111 | template <class T> |
| 112 | struct <a href= |
| 113 | "http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>; |
| 114 | |
| 115 | template <class T> |
| 116 | struct <a href= |
| 117 | "../utility/CopyConstructible.html">CopyConstructible</a>; // Standard ref 20.1.3 |
| 118 | |
| 119 | template <class T> |
| 120 | struct <a href= |
| 121 | "http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</a>; // Standard ref 20.1.1 |
| 122 | |
| 123 | template <class T> |
| 124 | struct <a href= |
| 125 | "../utility/LessThanComparable.html">LessThanComparable</a>; // Standard ref 20.1.2 |
| 126 | |
| 127 | template <class T> |
| 128 | struct Comparable; // The SGI STL <a href= |
| 129 | "http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</a> concept |
| 130 | </pre> |
| 131 | |
| 132 | <h3><a name="iterator-concepts" id="iterator-concepts">Iterator Concept |
| 133 | Checking Classes</a></h3> |
| 134 | <pre> |
| 135 | template <class Iter> |
| 136 | struct <a href= |
| 137 | "http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>; // Standard ref 24.1.1 Table 72 |
| 138 | |
| 139 | template <class Iter, class T> |
| 140 | struct <a href= |
| 141 | "http://www.sgi.com/tech/stl/OutputIterator.html">OutputIterator</a>; // Standard ref 24.1.2 Table 73 |
| 142 | |
| 143 | template <class Iter> |
| 144 | struct <a href= |
| 145 | "http://www.sgi.com/tech/stl/ForwardIterator.html">ForwardIterator</a>; // Standard ref 24.1.3 Table 74 |
| 146 | |
| 147 | template <class Iter> |
| 148 | struct Mutable_ForwardIterator; |
| 149 | |
| 150 | template <class Iter> |
| 151 | struct <a href= |
| 152 | "http://www.sgi.com/tech/stl/BidirectionalIterator.html">BidirectionalIterator</a>; // Standard ref 24.1.4 Table 75 |
| 153 | |
| 154 | template <class Iter> |
| 155 | struct Mutable_BidirectionalIterator; |
| 156 | |
| 157 | template <class Iter> |
| 158 | struct <a href= |
| 159 | "http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>; // Standard ref 24.1.5 Table 76 |
| 160 | |
| 161 | template <class Iter> |
| 162 | struct Mutable_RandomAccessIterator; |
| 163 | </pre> |
| 164 | |
| 165 | <h3><a name="function-object-concepts" id= |
| 166 | "function-object-concepts">Function Object Concept Checking |
| 167 | Classes</a></h3> |
| 168 | <pre> |
| 169 | #include "boost/concept_check.hpp" |
| 170 | |
| 171 | template <class Func, class Return> |
| 172 | struct <a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a>; |
| 173 | |
| 174 | template <class Func, class Return, class Arg> |
| 175 | struct <a href= |
| 176 | "http://www.sgi.com/tech/stl/UnaryFunction.html">UnaryFunction</a>; |
| 177 | |
| 178 | template <class Func, class Return, class First, class Second> |
| 179 | struct <a href= |
| 180 | "http://www.sgi.com/tech/stl/BinaryFunction.html">BinaryFunction</a>; |
| 181 | |
| 182 | template <class Func, class Arg> |
| 183 | struct Unary<a href= |
| 184 | "http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>; |
| 185 | |
| 186 | template <class Func, class First, class Second> |
| 187 | struct <a href= |
| 188 | "http://www.sgi.com/tech/stl/BinaryPredicate.html">BinaryPredicate</a>; |
| 189 | |
| 190 | template <class Func, class First, class Second> |
| 191 | struct Const_BinaryPredicate; |
| 192 | |
| 193 | template <class Func, class Return> |
| 194 | struct <a href= |
| 195 | "http://www.sgi.com/tech/stl/AdaptableGenerator.html">AdaptableGenerator</a>; |
| 196 | |
| 197 | template <class Func, class Return, class Arg> |
| 198 | struct <a href= |
| 199 | "http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html">AdaptableUnaryFunction</a>; |
| 200 | |
| 201 | template <class Func, class First, class Second> |
| 202 | struct <a href= |
| 203 | "http://www.sgi.com/tech/stl/AdaptableBinaryFunction.html">AdaptableBinaryFunction</a>; |
| 204 | |
| 205 | template <class Func, class Arg> |
| 206 | struct <a href= |
| 207 | "http://www.sgi.com/tech/stl/AdaptablePredicate.html">AdaptablePredicate</a>; |
| 208 | |
| 209 | template <class Func, class First, class Second> |
| 210 | struct <a href= |
| 211 | "http://www.sgi.com/tech/stl/AdaptableBinaryPredicate.html">AdaptableBinaryPredicate</a>; |
| 212 | </pre> |
| 213 | |
| 214 | <h3><a name="container-concepts" id="container-concepts">Container Concept |
| 215 | Checking Classes</a></h3> |
| 216 | <pre> |
| 217 | #include "boost/concept_check.hpp" |
| 218 | |
| 219 | template <class C> |
| 220 | struct <a href= |
| 221 | "http://www.sgi.com/tech/stl/Container.html">Container</a>; // Standard ref 23.1 Table 65 |
| 222 | |
| 223 | template <class C> |
| 224 | struct Mutable_Container; |
| 225 | |
| 226 | template <class C> |
| 227 | struct <a href= |
| 228 | "http://www.sgi.com/tech/stl/ForwardContainer.html">ForwardContainer</a>; |
| 229 | |
| 230 | template <class C> |
| 231 | struct Mutable_ForwardContainer; |
| 232 | |
| 233 | template <class C> |
| 234 | struct <a href= |
| 235 | "http://www.sgi.com/tech/stl/ReversibleContainer.html">ReversibleContainer</a>; // Standard ref 23.1 Table 66 |
| 236 | |
| 237 | template <class C> |
| 238 | struct Mutable_ReversibleContainer; |
| 239 | |
| 240 | template <class C> |
| 241 | struct <a href= |
| 242 | "http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a>; |
| 243 | |
| 244 | template <class C> |
| 245 | struct Mutable_RandomAccessContainer; |
| 246 | |
| 247 | template <class C> |
| 248 | struct <a href= |
| 249 | "http://www.sgi.com/tech/stl/Sequence.html">Sequence</a>; // Standard ref 23.1.1 |
| 250 | |
| 251 | template <class C> |
| 252 | struct <a href= |
| 253 | "http://www.sgi.com/tech/stl/FrontInsertionSequence.html">FrontInsertionSequence</a>; |
| 254 | |
| 255 | template <class C> |
| 256 | struct <a href= |
| 257 | "http://www.sgi.com/tech/stl/BackInsertionSequence.html">BackInsertionSequence</a>; |
| 258 | |
| 259 | template <class C> |
| 260 | struct <a href= |
| 261 | "http://www.sgi.com/tech/stl/AssociativeContainer.html">AssociativeContainer</a>; // Standard ref 23.1.2 Table 69 |
| 262 | |
| 263 | template <class C> |
| 264 | struct <a href= |
| 265 | "http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">UniqueAssociativeContainer</a>; |
| 266 | |
| 267 | template <class C> |
| 268 | struct <a href= |
| 269 | "http://www.sgi.com/tech/stl/MultipleAssociativeContainer.html">MultipleAssociativeContainer</a>; |
| 270 | |
| 271 | template <class C> |
| 272 | struct <a href= |
| 273 | "http://www.sgi.com/tech/stl/SimpleAssociativeContainer.html">SimpleAssociativeContainer</a>; |
| 274 | |
| 275 | template <class C> |
| 276 | struct <a href= |
| 277 | "http://www.sgi.com/tech/stl/PairAssociativeContainer.html">PairAssociativeContainer</a>; |
| 278 | |
| 279 | template <class C> |
| 280 | struct <a href= |
| 281 | "http://www.sgi.com/tech/stl/SortedAssociativeContainer.html">SortedAssociativeContainer</a>; |
| 282 | |
| 283 | template <class C> |
| 284 | struct <a href= |
| 285 | "../utility/Collection.html">Collection</a>; |
| 286 | </pre> |
| 287 | |
| 288 | <h3><a name="basic-archetype" id="basic-archetype">Basic Archetype |
| 289 | Classes</a></h3> |
| 290 | <pre> |
| 291 | #include "boost/concept_archetype.hpp" |
| 292 | |
| 293 | template <class T = int> |
| 294 | class null_archetype; // A type that models no concepts. |
| 295 | |
| 296 | template <class Base = null_archetype> |
| 297 | class default_constructible_archetype; |
| 298 | |
| 299 | template <class Base = null_archetype> |
| 300 | class assignable_archetype; |
| 301 | |
| 302 | template <class Base = null_archetype> |
| 303 | class copy_constructible_archetype; |
| 304 | |
| 305 | template <class Base = null_archetype> |
| 306 | class equality_comparable_archetype; |
| 307 | |
| 308 | template <class T, class Base = null_archetype> |
| 309 | class convertible_to_archetype; |
| 310 | </pre> |
| 311 | |
| 312 | <h3><a name="iterator-archetype" id="iterator-archetype">Iterator Archetype |
| 313 | Classes</a></h3> |
| 314 | <pre> |
| 315 | #include "boost/concept_archetype.hpp" |
| 316 | |
| 317 | template <class ValueType> |
| 318 | class trivial_iterator_archetype; |
| 319 | |
| 320 | template <class ValueType> |
| 321 | class mutable_trivial_iterator_archetype; |
| 322 | |
| 323 | template <class ValueType> |
| 324 | class input_iterator_archetype; |
| 325 | |
| 326 | template <class ValueType> |
| 327 | class forward_iterator_archetype; |
| 328 | |
| 329 | template <class ValueType> |
| 330 | class bidirectional_iterator_archetype; |
| 331 | |
| 332 | template <class ValueType> |
| 333 | class random_access_iterator_archetype; |
| 334 | </pre> |
| 335 | |
| 336 | <h3><a name="function-object-archetype" id= |
| 337 | "function-object-archetype">Function Object Archetype Classes</a></h3> |
| 338 | <pre> |
| 339 | #include "boost/concept_archetype.hpp" |
| 340 | |
| 341 | template <class Arg, class Return> |
| 342 | class unary_function_archetype; |
| 343 | |
| 344 | template <class Arg1, class Arg2, class Return> |
| 345 | class binary_function_archetype; |
| 346 | |
| 347 | template <class Arg> |
| 348 | class predicate_archetype; |
| 349 | |
| 350 | template <class Arg1, class Arg2> |
| 351 | class binary_predicate_archetype; |
| 352 | </pre> |
| 353 | |
| 354 | <h3><a name="container-archetype" id="container-archetype">Container |
| 355 | Archetype Classes</a></h3> |
| 356 | <pre> |
| 357 | UNDER CONSTRUCTION |
| 358 | </pre> |
| 359 | |
| 360 | <h3><a name="deprecated-functions" id="deprecated-functions">Deprecated |
| 361 | Functions</a></h3> |
| 362 | <pre> |
| 363 | #include "boost/concept_check.hpp" |
| 364 | |
| 365 | template <class Concept> |
| 366 | void function_requires(); |
| 367 | </pre> |
| 368 | |
| 369 | <p><code>function_requires()</code> has been deprecated in favor of <code>BOOST_CONCEPT_ASSERT</code>. |
| 370 | This means that <del><code>function_requires< Concept<Type> >();</code></del> |
| 371 | becomes <code>BOOST_CONCEPT_ASSERT((Concept<Type>));</code> |
| 372 | (don't forget to <code>#include "boost/concept/assert.hpp"</code>). |
| 373 | |
| 374 | |
| 375 | <h3><a name="deprecated-macros" id="deprecated-macros">Deprecated |
| 376 | Macros</a></h3> |
| 377 | <pre> |
| 378 | #include "boost/concept_check.hpp" |
| 379 | |
| 380 | // Apply concept checks in class definitions. |
| 381 | BOOST_CLASS_REQUIRE(<i>type</i>, <i>namespace-of-concept</i>, <i>concept</i>); |
| 382 | BOOST_CLASS_REQUIRE2(<i>type1</i>, <i>type2</i>, <i>namespace-of-concept</i>, <i>concept</i>); |
| 383 | BOOST_CLASS_REQUIRE3(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>namespace-of-concept</i>, <i>concept</i>); |
| 384 | BOOST_CLASS_REQUIRE4(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>type4</i>, <i>namespace-of-concept</i>, <i>concept</i>); |
| 385 | |
| 386 | // Apply concept checks in class definitions. |
| 387 | BOOST_CLASS_REQUIRES(<i>type</i>, <i>concept</i>); |
| 388 | BOOST_CLASS_REQUIRES2(<i>type1</i>, <i>type2</i>, <i>concept</i>); |
| 389 | BOOST_CLASS_REQUIRES3(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>concept</i>); |
| 390 | BOOST_CLASS_REQUIRES4(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>type4</i>, <i>concept</i>); |
| 391 | </pre> |
| 392 | |
| 393 | <h3><a name="deprecated-concept-checking-classes" id= |
| 394 | "deprecated-concept-checking-classes">Deprecated Concept Checking |
| 395 | Classes</a></h3> |
| 396 | |
| 397 | <p>For each of the concepts documented here, the library includes an |
| 398 | identical concept checking class whose name ends in |
| 399 | “<code>Concept</code>” For example, in |
| 400 | addition to <code>RandomAccessIterator</code>, the library defines a |
| 401 | <code>RandomAccessIteratorConcept</code> class template.</p> |
| 402 | |
| 403 | <p><a href="./concept_check.htm">Back to Introduction</a><br /> |
| 404 | <a href="./implementation.htm">Prev: Implementation</a><br /></p> |
| 405 | <hr /> |
| 406 | |
| 407 | <table> |
| 408 | <tr valign="top"> |
| 409 | <td nowrap="nowrap">Copyright © 2000</td> |
| 410 | |
| 411 | <td><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>(<a href= |
| 412 | "mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</a>) Andrew |
| 413 | Lumsdaine(<a href="mailto:lums@osl.iu.edu">lums@osl.iu.edu</a>), 2007 |
| 414 | <a href="mailto:dave@boost-consulting.com">David Abrahams</a>.</td> |
| 415 | </tr> |
| 416 | </table> |
| 417 | </body> |
| 418 | </html> |