📄 concepts.hpp
字号:
typedef I1 iterator1_type; typedef I2 iterator2_type; static void constraints () { BidirectionalIteratorConcept<iterator1_type>::constraints (); BidirectionalIteratorConcept<iterator2_type>::constraints (); Indexed2DIteratorConcept<iterator1_type>::constraints (); Indexed2DIteratorConcept<iterator2_type>::constraints (); } }; template<class I1, class I2> struct MutableIndexedBidirectional2DIteratorConcept { typedef I1 iterator1_type; typedef I2 iterator2_type; static void constraints () { MutableBidirectionalIteratorConcept<iterator1_type>::constraints (); MutableBidirectionalIteratorConcept<iterator2_type>::constraints (); Indexed2DIteratorConcept<iterator1_type>::constraints (); Indexed2DIteratorConcept<iterator2_type>::constraints (); } }; template<class I1, class I2> struct IndexedRandomAccess2DIteratorConcept { typedef I1 iterator1_type; typedef I2 iterator2_type; static void constraints () { RandomAccessIteratorConcept<iterator1_type>::constraints (); RandomAccessIteratorConcept<iterator2_type>::constraints (); Indexed2DIteratorConcept<iterator1_type>::constraints (); Indexed2DIteratorConcept<iterator2_type>::constraints (); } }; template<class I1, class I2> struct MutableIndexedRandomAccess2DIteratorConcept { typedef I1 iterator1_type; typedef I2 iterator2_type; static void constraints () { MutableRandomAccessIteratorConcept<iterator1_type>::constraints (); MutableRandomAccessIteratorConcept<iterator2_type>::constraints (); Indexed2DIteratorConcept<iterator1_type>::constraints (); Indexed2DIteratorConcept<iterator2_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 () { DefaultConstructibleConcept<generator_type>::constraints (); 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 S> struct ScalarExpressionConcept { typedef S scalar_type; typedef typename S::value_type value_type; static void constraints () { DefaultConstructibleConcept<scalar_type>::constraints (); scalar_type s = scalar_type (); value_type t; // Conversion t = s; ignore_unused_variable_warning (t); } }; template<class V> struct VectorExpressionConcept { typedef V vector_type; typedef typename V::type_category type_category; typedef typename V::size_type size_type; typedef typename V::value_type value_type; typedef typename V::const_iterator const_iterator_type; typedef typename V::const_reverse_iterator const_reverse_iterator_type; static void constraints () { DefaultConstructibleConcept<vector_type>::constraints (); vector_type v = vector_type (); 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 ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -