
#include "boost/concept/assert.hpp"
BOOST_CONCEPT_ASSERT((concept checking class template specialization));
作用:如果概念不滿足,引發一個編譯錯誤。
說明:該宏可以在全局範圍、類範圍或函數範圍中使用。
#include "boost/concept/requires.hpp"
template <…template parameters…> BOOST_CONCEPT_REQUIRES( ((concept checking class template specialization1))
((concept checking class template specialization2))…
((concept checking class template specializationn)), (function return type)
) function_template_name(…function parameters…)
作用:如果給定的概念不被滿足,引發一個編譯錯誤。
說明:該宏被規定為用於替代一個函數模板的返回類型。
#include "boost/concept_check.hpp"
template <class T>
struct Integer; // T 是內建的整數類型嗎?
template <class T>
struct SignedInteger; // T 是內建的有符號整數類型嗎?
template <class T>
struct UnsignedInteger; // T 是內建的無符號整數類型嗎?
template <class X, class Y>
struct Convertible; // X 可以轉換為 Y 嗎?
template <class T>
struct Assignable; // 參考標準 23.1
template <class T>
struct SGIAssignable;
template <class T>
struct DefaultConstructible;
template <class T>
struct CopyConstructible; // 參考標準 20.1.3
template <class T>
struct EqualityComparable; // 參考標準 20.1.1
template <class T>
struct LessThanComparable; // 參考標準 20.1.2
template <class T>
struct Comparable; // SGI STL 的 LessThanComparable 概念
template <class Iter>
struct InputIterator; // 參考標準 24.1.1 表 72
template <class Iter, class T>
struct OutputIterator; // 參考標準 24.1.2 表 73
template <class Iter>
struct ForwardIterator; // 參考標準 24.1.3 表 74
template <class Iter>
struct Mutable_ForwardIterator;
template <class Iter>
struct BidirectionalIterator; // 參考標準 24.1.4 表 75
template <class Iter>
struct Mutable_BidirectionalIterator;
template <class Iter>
struct RandomAccessIterator; // 參考標準 24.1.5 表 76
template <class Iter>
struct Mutable_RandomAccessIterator;
#include "boost/concept_check.hpp"
template <class Func, class Return>
struct Generator;
template <class Func, class Return, class Arg>
struct UnaryFunction;
template <class Func, class Return, class First, class Second>
struct BinaryFunction;
template <class Func, class Arg>
struct UnaryPredicate;
template <class Func, class First, class Second>
struct BinaryPredicate;
template <class Func, class First, class Second>
struct Const_BinaryPredicate;
template <class Func, class Return>
struct AdaptableGenerator;
template <class Func, class Return, class Arg>
struct AdaptableUnaryFunction;
template <class Func, class First, class Second>
struct AdaptableBinaryFunction;
template <class Func, class Arg>
struct AdaptablePredicate;
template <class Func, class First, class Second>
struct AdaptableBinaryPredicate;
#include "boost/concept_check.hpp"
template <class C>
struct Container; // 參考標準 23.1 表 65
template <class C>
struct Mutable_Container;
template <class C>
struct ForwardContainer;
template <class C>
struct Mutable_ForwardContainer;
template <class C>
struct ReversibleContainer; // 參考標準 23.1 表 66
template <class C>
struct Mutable_ReversibleContainer;
template <class C>
struct RandomAccessContainer;
template <class C>
struct Mutable_RandomAccessContainer;
template <class C>
struct Sequence; // 參考標準 23.1.1
template <class C>
struct FrontInsertionSequence;
template <class C>
struct BackInsertionSequence;
template <class C>
struct AssociativeContainer; // 參考標準 23.1.2 表 69
template <class C>
struct UniqueAssociativeContainer;
template <class C>
struct MultipleAssociativeContainer;
template <class C>
struct SimpleAssociativeContainer;
template <class C>
struct PairAssociativeContainer;
template <class C>
struct SortedAssociativeContainer;
#include "boost/concept_archetype.hpp"
template <class T = int>
class null_archetype; // 沒有概念的類型
template <class Base = null_archetype>
class default_constructible_archetype;
template <class Base = null_archetype>
class assignable_archetype;
template <class Base = null_archetype>
class copy_constructible_archetype;
template <class Base = null_archetype>
class equality_comparable_archetype;
template <class T, class Base = null_archetype>
class convertible_to_archetype;
#include "boost/concept_archetype.hpp"
template <class ValueType>
class trivial_iterator_archetype;
template <class ValueType>
class mutable_trivial_iterator_archetype;
template <class ValueType>
class input_iterator_archetype;
template <class ValueType>
class forward_iterator_archetype;
template <class ValueType>
class bidirectional_iterator_archetype;
template <class ValueType>
class random_access_iterator_archetype;
#include "boost/concept_archetype.hpp"
template <class Arg, class Return>
class unary_function_archetype;
template <class Arg1, class Arg2, class Return>
class binary_function_archetype;
template <class Arg>
class predicate_archetype;
template <class Arg1, class Arg2>
class binary_predicate_archetype;
UNDER CONSTRUCTION
#include "boost/concept_check.hpp"
template <class Concept>
void function_requires();
#include "boost/concept_check.hpp"
// 在類定義中使用概念檢查
BOOST_CLASS_REQUIRE(type, namespace-of-concept, concept);
BOOST_CLASS_REQUIRE2(type1, type2, namespace-of-concept, concept);
BOOST_CLASS_REQUIRE3(type1, type2, type3, namespace-of-concept, concept);
BOOST_CLASS_REQUIRE4(type1, type2, type3, type4, namespace-of-concept, concept);
// 在類定義中使用概念檢查
BOOST_CLASS_REQUIRES(type, concept);
BOOST_CLASS_REQUIRES2(type1, type2, concept);
BOOST_CLASS_REQUIRES3(type1, type2, type3, concept);
BOOST_CLASS_REQUIRES4(type1, type2, type3, type4, concept);
對於本文檔中所列出的每一個概念,本庫包含了一個相同的概念檢查類,其名字以“Concept”結尾。例如,除了 RandomAccessIterator, 本庫還定義了一個
RandomAccessIteratorConcept 類模板。
Back to Introduction 返回到簡介
Prev: Implementation 實現
| Copyright © 2000 | Jeremy Siek(jsiek@osl.iu.edu) Andrew Lumsdaine(lums@osl.iu.edu), 2007 David Abrahams. |