📄 concepts.hpp
字号:
struct IndexedRandomAccess2DIteratorConcept {
typedef I1 subiterator1_type;
typedef I2 subiterator2_type;
static void constraints () {
RandomAccessIteratorConcept<subiterator1_type>::constraints ();
RandomAccessIteratorConcept<subiterator2_type>::constraints ();
Indexed2DIteratorConcept<subiterator1_type>::constraints ();
Indexed2DIteratorConcept<subiterator2_type>::constraints ();
}
};
template<class I1, class I2>
struct MutableIndexedRandomAccess2DIteratorConcept {
typedef I1 subiterator1_type;
typedef I2 subiterator2_type;
static void constraints () {
MutableRandomAccessIteratorConcept<subiterator1_type>::constraints ();
MutableRandomAccessIteratorConcept<subiterator2_type>::constraints ();
Indexed2DIteratorConcept<subiterator1_type>::constraints ();
Indexed2DIteratorConcept<subiterator2_type>::constraints ();
}
};
template<class C>
struct ContainerConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::const_iterator const_iterator_type;
static void constraints () {
DefaultConstructibleConcept<container_type>::constraints ();
container_type c = container_type ();
size_type n (0);
// Beginning of range
const_iterator_type cit_begin (c.begin ());
// End of range
const_iterator_type cit_end (c.end ());
// Size
n = c.size ();
ignore_unused_variable_warning (cit_end);
ignore_unused_variable_warning (cit_begin);
ignore_unused_variable_warning (n);
}
};
template<class C>
struct MutableContainerConcept {
typedef C container_type;
typedef typename C::iterator iterator_type;
static void constraints () {
AssignableConcept<container_type>::constraints (container_type ());
ContainerConcept<container_type>::constraints ();
container_type c = container_type (), c1 = container_type (), c2 = container_type ();
// Beginning of range
iterator_type it_begin (c.begin ());
// End of range
iterator_type it_end (c.end ());
// Swap
c1.swap (c2);
ignore_unused_variable_warning (it_end);
ignore_unused_variable_warning (it_begin);
}
};
template<class C>
struct ReversibleContainerConcept {
typedef C container_type;
typedef typename C::const_reverse_iterator const_reverse_iterator_type;
static void constraints () {
ContainerConcept<container_type>::constraints ();
const container_type cc = container_type ();
// Beginning of reverse range
const_reverse_iterator_type crit_begin (cc.rbegin ());
// End of reverse range
const_reverse_iterator_type crit_end (cc.rend ());
ignore_unused_variable_warning (crit_end);
ignore_unused_variable_warning (crit_begin);
}
};
template<class C>
struct MutableReversibleContainerConcept {
typedef C container_type;
typedef typename C::reverse_iterator reverse_iterator_type;
static void constraints () {
MutableContainerConcept<container_type>::constraints ();
ReversibleContainerConcept<container_type>::constraints ();
container_type c = container_type ();
// Beginning of reverse range
reverse_iterator_type rit_begin (c.rbegin ());
// End of reverse range
reverse_iterator_type rit_end (c.rend ());
ignore_unused_variable_warning (rit_end);
ignore_unused_variable_warning (rit_begin);
}
};
template<class C>
struct RandomAccessContainerConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::value_type value_type;
static void constraints () {
ReversibleContainerConcept<container_type>::constraints ();
container_type c = container_type ();
size_type n (0);
value_type t = value_type ();
// Element access
t = c [n];
ignore_unused_variable_warning (t);
}
};
template<class C>
struct MutableRandomAccessContainerConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::value_type value_type;
static void constraints () {
MutableReversibleContainerConcept<container_type>::constraints ();
RandomAccessContainerConcept<container_type>::constraints ();
container_type c = container_type ();
size_type n (0);
value_type t = value_type ();
// Element access
c [n] = t;
}
};
template<class C>
struct StorageArrayConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::value_type value_type;
static void constraints () {
RandomAccessContainerConcept<container_type>::constraints ();
size_type n (0);
// Sizing constructor
container_type c = container_type (n);
// Initialised sizing constructor
container_type (n, value_type (5));
ignore_unused_variable_warning (c);
}
};
template<class C>
struct MutableStorageArrayConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::value_type value_type;
typedef typename C::iterator iterator_type;
static void constraints () {
MutableRandomAccessContainerConcept<container_type>::constraints ();
size_type n (0);
// Sizing constructor
container_type c = container_type (n);
// Initialised sizing constructor
c = container_type (n, value_type (3));
// Resize
c.resize (n, value_type (5));
// Resize - none preserving
c.resize (n);
}
};
template<class C>
struct StorageSparseConcept {
typedef C container_type;
typedef typename C::size_type size_type;
static void constraints () {
ReversibleContainerConcept<container_type>::constraints ();
}
};
template<class C>
struct MutableStorageSparseConcept {
typedef C container_type;
typedef typename C::size_type size_type;
typedef typename C::value_type value_type;
typedef typename C::iterator iterator_type;
static void constraints () {
MutableReversibleContainerConcept<container_type>::constraints ();
container_type c = container_type ();
value_type t = value_type ();
iterator_type it = iterator_type (), it1 = iterator_type (), it2 = iterator_type ();
// Insert
c.insert (it, t);
// Erase
c.erase (it);
// Range erase
c.erase (it1, it2);
// Clear
c.clear ();
}
};
template<class G>
struct IndexSetConcept {
typedef G generator_type;
typedef typename G::size_type size_type;
typedef typename G::value_type value_type;
static void constraints () {
AssignableConcept<generator_type>::constraints (generator_type ());
ReversibleContainerConcept<generator_type>::constraints ();
generator_type g = generator_type ();
size_type n (0);
value_type t;
// Element access
t = g (n);
ignore_unused_variable_warning (t);
}
};
template<class SE>
struct ScalarExpressionConcept {
typedef SE scalar_expression_type;
typedef typename SE::value_type value_type;
static void constraints () {
scalar_expression_type *sp;
scalar_expression_type s = *sp;
value_type t;
// Conversion
t = s;
ignore_unused_variable_warning (t);
}
};
template<class VE>
struct VectorExpressionConcept {
typedef VE vector_expression_type;
typedef typename VE::type_category type_category;
typedef typename VE::size_type size_type;
typedef typename VE::value_type value_type;
typedef typename VE::const_iterator const_iterator_type;
typedef typename VE::const_reverse_iterator const_reverse_iterator_type;
static void constraints () {
vector_expression_type *vp;
const vector_expression_type *cvp;
vector_expression_type v = *vp;
const vector_expression_type cv = *cvp;
size_type n (0), i (0);
value_type t;
// Find (internal?)
const_iterator_type cit (v.find (i));
// Beginning of range
const_iterator_type cit_begin (v.begin ());
// End of range
const_iterator_type cit_end (v.end ());
// Size
n = v.size ();
// Beginning of reverse range
const_reverse_iterator_type crit_begin (cv.rbegin ());
// End of reverse range
const_reverse_iterator_type crit_end (cv.rend ());
// Element access
t = v (i);
ignore_unused_variable_warning (n);
ignore_unused_variable_warning (cit);
ignore_unused_variable_warning (cit_begin);
ignore_unused_variable_warning (cit_end);
ignore_unused_variable_warning (crit_begin);
ignore_unused_variable_warning (crit_end);
ignore_unused_variable_warning (t);
}
};
template<class VE>
struct MutableVectorExpressionConcept {
typedef VE vector_expression_type;
typedef typename VE::size_type size_type;
typedef typename VE::value_type value_type;
typedef typename VE::iterator iterator_type;
typedef typename VE::reverse_iterator reverse_iterator_type;
static void constraints () {
vector_expression_type *vp;
AssignableConcept<vector_expression_type>::constraints (*vp);
VectorExpressionConcept<vector_expression_type>::constraints ();
vector_expression_type v = *vp, v1 = *vp, v2 = *vp;
size_type i (0);
value_type t = value_type ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -