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 61BOOST_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> 73BOOST_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 91template <class T> 92struct Integer; // Is T a built-in integer type? 93 94template <class T> 95struct SignedInteger; // Is T a built-in signed integer type? 96 97template <class T> 98struct UnsignedInteger; // Is T a built-in unsigned integer type? 99 100template <class X, class Y> 101struct Convertible; // Is X convertible to Y? 102 103template <class T> 104struct <a href= 105"../utility/Assignable.html">Assignable</a>; // Standard ref 23.1 106 107template <class T> 108struct SGI<a href= 109"http://www.boost.org/sgi/stl/Assignable.html">Assignable</a>; 110 111template <class T> 112struct <a href= 113"http://www.boost.org/sgi/stl/DefaultConstructible.html">DefaultConstructible</a>; 114 115template <class T> 116struct <a href= 117"../utility/CopyConstructible.html">CopyConstructible</a>; // Standard ref 20.1.3 118 119template <class T> 120struct <a href= 121"http://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</a>; // Standard ref 20.1.1 122 123template <class T> 124struct <a href= 125"../utility/LessThanComparable.html">LessThanComparable</a>; // Standard ref 20.1.2 126 127template <class T> 128struct Comparable; // The SGI STL <a href= 129"http://www.boost.org/sgi/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> 135template <class Iter> 136struct <a href= 137"http://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>; // Standard ref 24.1.1 Table 72 138 139template <class Iter, class T> 140struct <a href= 141"http://www.boost.org/sgi/stl/OutputIterator.html">OutputIterator</a>; // Standard ref 24.1.2 Table 73 142 143template <class Iter> 144struct <a href= 145"http://www.boost.org/sgi/stl/ForwardIterator.html">ForwardIterator</a>; // Standard ref 24.1.3 Table 74 146 147template <class Iter> 148struct Mutable_ForwardIterator; 149 150template <class Iter> 151struct <a href= 152"http://www.boost.org/sgi/stl/BidirectionalIterator.html">BidirectionalIterator</a>; // Standard ref 24.1.4 Table 75 153 154template <class Iter> 155struct Mutable_BidirectionalIterator; 156 157template <class Iter> 158struct <a href= 159"http://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>; // Standard ref 24.1.5 Table 76 160 161template <class Iter> 162struct 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 171template <class Func, class Return> 172struct <a href="http://www.boost.org/sgi/stl/Generator.html">Generator</a>; 173 174template <class Func, class Return, class Arg> 175struct <a href= 176"http://www.boost.org/sgi/stl/UnaryFunction.html">UnaryFunction</a>; 177 178template <class Func, class Return, class First, class Second> 179struct <a href= 180"http://www.boost.org/sgi/stl/BinaryFunction.html">BinaryFunction</a>; 181 182template <class Func, class Arg> 183struct Unary<a href= 184"http://www.boost.org/sgi/stl/Predicate.html">Predicate</a>; 185 186template <class Func, class First, class Second> 187struct <a href= 188"http://www.boost.org/sgi/stl/BinaryPredicate.html">BinaryPredicate</a>; 189 190template <class Func, class First, class Second> 191struct Const_BinaryPredicate; 192 193template <class Func, class Return> 194struct <a href= 195"http://www.boost.org/sgi/stl/AdaptableGenerator.html">AdaptableGenerator</a>; 196 197template <class Func, class Return, class Arg> 198struct <a href= 199"http://www.boost.org/sgi/stl/AdaptableUnaryFunction.html">AdaptableUnaryFunction</a>; 200 201template <class Func, class First, class Second> 202struct <a href= 203"http://www.boost.org/sgi/stl/AdaptableBinaryFunction.html">AdaptableBinaryFunction</a>; 204 205template <class Func, class Arg> 206struct <a href= 207"http://www.boost.org/sgi/stl/AdaptablePredicate.html">AdaptablePredicate</a>; 208 209template <class Func, class First, class Second> 210struct <a href= 211"http://www.boost.org/sgi/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 219template <class C> 220struct <a href= 221"http://www.boost.org/sgi/stl/Container.html">Container</a>; // Standard ref 23.1 Table 65 222 223template <class C> 224struct Mutable_Container; 225 226template <class C> 227struct <a href= 228"http://www.boost.org/sgi/stl/ForwardContainer.html">ForwardContainer</a>; 229 230template <class C> 231struct Mutable_ForwardContainer; 232 233template <class C> 234struct <a href= 235"http://www.boost.org/sgi/stl/ReversibleContainer.html">ReversibleContainer</a>; // Standard ref 23.1 Table 66 236 237template <class C> 238struct Mutable_ReversibleContainer; 239 240template <class C> 241struct <a href= 242"http://www.boost.org/sgi/stl/RandomAccessContainer.html">RandomAccessContainer</a>; 243 244template <class C> 245struct Mutable_RandomAccessContainer; 246 247template <class C> 248struct <a href= 249"http://www.boost.org/sgi/stl/Sequence.html">Sequence</a>; // Standard ref 23.1.1 250 251template <class C> 252struct <a href= 253"http://www.boost.org/sgi/stl/FrontInsertionSequence.html">FrontInsertionSequence</a>; 254 255template <class C> 256struct <a href= 257"http://www.boost.org/sgi/stl/BackInsertionSequence.html">BackInsertionSequence</a>; 258 259template <class C> 260struct <a href= 261"http://www.boost.org/sgi/stl/AssociativeContainer.html">AssociativeContainer</a>; // Standard ref 23.1.2 Table 69 262 263template <class C> 264struct <a href= 265"http://www.boost.org/sgi/stl/UniqueAssociativeContainer.html">UniqueAssociativeContainer</a>; 266 267template <class C> 268struct <a href= 269"http://www.boost.org/sgi/stl/MultipleAssociativeContainer.html">MultipleAssociativeContainer</a>; 270 271template <class C> 272struct <a href= 273"http://www.boost.org/sgi/stl/SimpleAssociativeContainer.html">SimpleAssociativeContainer</a>; 274 275template <class C> 276struct <a href= 277"http://www.boost.org/sgi/stl/PairAssociativeContainer.html">PairAssociativeContainer</a>; 278 279template <class C> 280struct <a href= 281"http://www.boost.org/sgi/stl/SortedAssociativeContainer.html">SortedAssociativeContainer</a>; 282 283template <class C> 284struct <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 293template <class T = int> 294class null_archetype; // A type that models no concepts. 295 296template <class Base = null_archetype> 297class default_constructible_archetype; 298 299template <class Base = null_archetype> 300class assignable_archetype; 301 302template <class Base = null_archetype> 303class copy_constructible_archetype; 304 305template <class Base = null_archetype> 306class equality_comparable_archetype; 307 308template <class T, class Base = null_archetype> 309class 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 317template <class ValueType> 318class trivial_iterator_archetype; 319 320template <class ValueType> 321class mutable_trivial_iterator_archetype; 322 323template <class ValueType> 324class input_iterator_archetype; 325 326template <class ValueType> 327class forward_iterator_archetype; 328 329template <class ValueType> 330class bidirectional_iterator_archetype; 331 332template <class ValueType> 333class 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 341template <class Arg, class Return> 342class unary_function_archetype; 343 344template <class Arg1, class Arg2, class Return> 345class binary_function_archetype; 346 347template <class Arg> 348class predicate_archetype; 349 350template <class Arg1, class Arg2> 351class binary_predicate_archetype; 352</pre> 353 354 <h3><a name="container-archetype" id="container-archetype">Container 355 Archetype Classes</a></h3> 356 <pre> 357UNDER 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 365template <class Concept> 366void 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. 381BOOST_CLASS_REQUIRE(<i>type</i>, <i>namespace-of-concept</i>, <i>concept</i>); 382BOOST_CLASS_REQUIRE2(<i>type1</i>, <i>type2</i>, <i>namespace-of-concept</i>, <i>concept</i>); 383BOOST_CLASS_REQUIRE3(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>namespace-of-concept</i>, <i>concept</i>); 384BOOST_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. 387BOOST_CLASS_REQUIRES(<i>type</i>, <i>concept</i>); 388BOOST_CLASS_REQUIRES2(<i>type1</i>, <i>type2</i>, <i>concept</i>); 389BOOST_CLASS_REQUIRES3(<i>type1</i>, <i>type2</i>, <i>type3</i>, <i>concept</i>); 390BOOST_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> 419