📄 concepts.hpp
字号:
// Find (internal?)
iterator_type it (v.find (i));
// Beginning of range
iterator_type it_begin (v.begin ());
// End of range
iterator_type it_end (v.end ());
// Swap
v1.swap (v2);
// Beginning of reverse range
reverse_iterator_type rit_begin (v.rbegin ());
// End of reverse range
reverse_iterator_type rit_end (v.rend ());
// Assignments
v2 = v1;
v2.assign (v1);
v2 += v1;
v2.plus_assign (v1);
v2 -= v1;
v2.minus_assign (v1);
v *= t;
ignore_unused_variable_warning (it);
ignore_unused_variable_warning (it_begin);
ignore_unused_variable_warning (it_end);
ignore_unused_variable_warning (rit_begin);
ignore_unused_variable_warning (rit_end);
}
};
template<class ME>
struct MatrixExpressionConcept {
typedef ME matrix_expression_type;
typedef typename ME::type_category type_category;
typedef typename ME::size_type size_type;
typedef typename ME::value_type value_type;
typedef typename ME::const_iterator1 const_subiterator1_type;
typedef typename ME::const_iterator2 const_subiterator2_type;
typedef typename ME::const_reverse_iterator1 const_reverse_subiterator1_type;
typedef typename ME::const_reverse_iterator2 const_reverse_subiterator2_type;
static void constraints () {
matrix_expression_type *mp;
const matrix_expression_type *cmp;
matrix_expression_type m = *mp;
const matrix_expression_type cm = *cmp;
size_type n (0), i (0), j (0);
value_type t;
// Find (internal?)
const_subiterator1_type cit1 (m.find1 (0, i, j));
const_subiterator2_type cit2 (m.find2 (0, i, j));
// Beginning of range
const_subiterator1_type cit1_begin (m.begin1 ());
const_subiterator2_type cit2_begin (m.begin2 ());
// End of range
const_subiterator1_type cit1_end (m.end1 ());
const_subiterator2_type cit2_end (m.end2 ());
// Size
n = m.size1 ();
n = m.size2 ();
// Beginning of reverse range
const_reverse_subiterator1_type crit1_begin (cm.rbegin1 ());
const_reverse_subiterator2_type crit2_begin (cm.rbegin2 ());
// End of reverse range
const_reverse_subiterator1_type crit1_end (cm.rend1 ());
const_reverse_subiterator2_type crit2_end (cm.rend2 ());
// Element access
t = m (i, j);
ignore_unused_variable_warning (n);
ignore_unused_variable_warning (cit1);
ignore_unused_variable_warning (cit2);
ignore_unused_variable_warning (cit1_begin);
ignore_unused_variable_warning (cit2_begin);
ignore_unused_variable_warning (cit1_end);
ignore_unused_variable_warning (cit2_end);
ignore_unused_variable_warning (crit1_begin);
ignore_unused_variable_warning (crit2_begin);
ignore_unused_variable_warning (crit1_end);
ignore_unused_variable_warning (crit2_end);
ignore_unused_variable_warning (t);
}
};
template<class ME>
struct MutableMatrixExpressionConcept {
typedef ME matrix_expression_type;
typedef typename ME::size_type size_type;
typedef typename ME::value_type value_type;
typedef typename ME::iterator1 subiterator1_type;
typedef typename ME::iterator2 subiterator2_type;
typedef typename ME::reverse_iterator1 reverse_subiterator1_type;
typedef typename ME::reverse_iterator2 reverse_subiterator2_type;
static void constraints () {
matrix_expression_type *mp;
AssignableConcept<matrix_expression_type>::constraints (*mp);
MatrixExpressionConcept<matrix_expression_type>::constraints ();
matrix_expression_type m = *mp, m1 = *mp, m2 = *mp;
size_type i (0), j (0);
value_type t = value_type ();
// Find (internal?)
subiterator1_type it1 (m.find1 (0, i, j));
subiterator2_type it2 (m.find2 (0, i, j));
// Beginning of range
subiterator1_type it1_begin (m.begin1 ());
subiterator2_type it2_begin (m.begin2 ());
// End of range
subiterator1_type it1_end (m.end1 ());
subiterator2_type it2_end (m.end2 ());
// Swap
m1.swap (m2);
// Beginning of reverse range
reverse_subiterator1_type rit1_begin (m.rbegin1 ());
reverse_subiterator2_type rit2_begin (m.rbegin2 ());
// End of reverse range
reverse_subiterator1_type rit1_end (m.rend1 ());
reverse_subiterator2_type rit2_end (m.rend2 ());
// Assignments
m2 = m1;
m2.assign (m1);
m2 += m1;
m2.plus_assign (m1);
m2 -= m1;
m2.minus_assign (m1);
m *= t;
ignore_unused_variable_warning (it1);
ignore_unused_variable_warning (it2);
ignore_unused_variable_warning (it1_begin);
ignore_unused_variable_warning (it2_begin);
ignore_unused_variable_warning (it1_end);
ignore_unused_variable_warning (it2_end);
ignore_unused_variable_warning (rit1_begin);
ignore_unused_variable_warning (rit2_begin);
ignore_unused_variable_warning (rit1_end);
ignore_unused_variable_warning (rit2_end);
}
};
template<class V>
struct VectorConcept {
typedef V vector_type;
typedef typename V::size_type size_type;
typedef typename V::value_type value_type;
typedef const value_type *const_pointer;
static void constraints () {
VectorExpressionConcept<vector_type>::constraints ();
size_type n (0);
size_type i (0);
// Sizing constructor
vector_type v (n);
// Element support
const_pointer p = v.find_element (i);
ignore_unused_variable_warning (p);
}
};
template<class V>
struct MutableVectorConcept {
typedef V vector_type;
typedef typename V::size_type size_type;
typedef typename V::value_type value_type;
typedef value_type *pointer;
static void constraints () {
VectorConcept<vector_type>::constraints ();
MutableVectorExpressionConcept<vector_type>::constraints ();
size_type n (0);
value_type t = value_type ();
size_type i (0);
// Sizing constructor
vector_type v (n);
// Element support
pointer p = v.find_element (i);
// Element assignment
value_type r = v.insert_element (i, t);
v.insert_element (i, t) = r;
// Zeroing
v.clear ();
// Resize
v.resize (n);
ignore_unused_variable_warning (p);
ignore_unused_variable_warning (r);
}
};
template<class V>
struct SparseVectorConcept {
typedef V vector_type;
typedef typename V::size_type size_type;
static void constraints () {
VectorConcept<vector_type>::constraints ();
}
};
template<class V>
struct MutableSparseVectorConcept {
typedef V vector_type;
typedef typename V::size_type size_type;
typedef typename V::value_type value_type;
static void constraints () {
SparseVectorConcept<vector_type>::constraints ();
MutableVectorConcept<vector_type>::constraints ();
size_type n (0);
size_type i (0);
// Sizing constructor
vector_type v (n);
// Element erasure
v.erase_element (i);
}
};
template<class M>
struct MatrixConcept {
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::value_type value_type;
typedef const value_type *const_pointer;
static void constraints () {
MatrixExpressionConcept<matrix_type>::constraints ();
size_type n (0);
size_type i (0), j (0);
// Sizing constructor
matrix_type m (n, n);
// Element support
#ifndef SKIP_BAD
const_pointer p = m.find_element (i, j);
#else
const_pointer p;
ignore_unused_variable_warning (i);
ignore_unused_variable_warning (j);
#endif
ignore_unused_variable_warning (p);
}
};
template<class M>
struct MutableMatrixConcept {
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::value_type value_type;
typedef value_type *pointer;
static void constraints () {
MatrixConcept<matrix_type>::constraints ();
MutableMatrixExpressionConcept<matrix_type>::constraints ();
size_type n (0);
value_type t = value_type ();
size_type i (0), j (0);
// Sizing constructor
matrix_type m (n, n);
// Element support
#ifndef SKIP_BAD
pointer p = m.find_element (i, j);
ignore_unused_variable_warning (i);
ignore_unused_variable_warning (j);
#else
pointer p;
#endif
// Element assigment
value_type r = m.insert_element (i, j, t);
m.insert_element (i, j, t) = r;
// Zeroing
m.clear ();
// Resize
m.resize (n, n);
m.resize (n, n, false);
ignore_unused_variable_warning (p);
ignore_unused_variable_warning (r);
}
};
template<class M>
struct SparseMatrixConcept {
typedef M matrix_type;
typedef typename M::size_type size_type;
static void constraints () {
MatrixConcept<matrix_type>::constraints ();
}
};
template<class M>
struct MutableSparseMatrixConcept {
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::value_type value_type;
static void constraints () {
SparseMatrixConcept<matrix_type>::constraints ();
MutableMatrixConcept<matrix_type>::constraints ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -