⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 concepts.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 5 页
字号:
////  Copyright (c) 2000-2002//  Joerg Walter, Mathias Koch////  Distributed under the Boost Software License, Version 1.0. (See//  accompanying file LICENSE_1_0.txt or copy at//  http://www.boost.org/LICENSE_1_0.txt)////  The authors gratefully acknowledge the support of//  GeNeSys mbH & Co. KG in producing this work.//#ifndef _BOOST_UBLAS_CONCEPTS_#define _BOOST_UBLAS_CONCEPTS_#include <boost/concept_check.hpp>// Concept checks based on ideas of Jeremy Sieknamespace boost { namespace numeric { namespace ublas {    template<class I>    struct Indexed1DIteratorConcept {        typedef I iterator_type;        void constraints () {            iterator_type it = iterator_type ();            // Index            it.index ();        }    };    template<class I>    struct IndexedBidirectional1DIteratorConcept {        typedef I iterator_type;        void constraints () {            function_requires< BidirectionalIteratorConcept<iterator_type> >();            function_requires< Indexed1DIteratorConcept<iterator_type> >();        }    };    template<class I>    struct Mutable_IndexedBidirectional1DIteratorConcept {        typedef I iterator_type;        void constraints () {            function_requires< Mutable_BidirectionalIteratorConcept<iterator_type> >();            function_requires< Indexed1DIteratorConcept<iterator_type> >();        }    };    template<class I>    struct IndexedRandomAccess1DIteratorConcept {        typedef I iterator_type;        void constraints () {            function_requires< RandomAccessIteratorConcept<iterator_type> >();            function_requires< Indexed1DIteratorConcept<iterator_type> >();        }    };    template<class I>    struct Mutable_IndexedRandomAccess1DIteratorConcept {        typedef I iterator_type;        void constraints () {            function_requires< Mutable_RandomAccessIteratorConcept<iterator_type> >();            function_requires< Indexed1DIteratorConcept<iterator_type> >();        }    };    template<class I>    struct Indexed2DIteratorConcept {        typedef I iterator_type;        typedef typename I::dual_iterator_type dual_iterator_type;        typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type;        void constraints () {            iterator_type it = iterator_type ();            // Indices            it.index1 ();            it.index2 ();            // Iterator begin/end            dual_iterator_type it_begin (it.begin ());            dual_iterator_type it_end (it.end ());            // Reverse iterator begin/end            dual_reverse_iterator_type it_rbegin (it.rbegin ());            dual_reverse_iterator_type it_rend (it.rend ());            ignore_unused_variable_warning (it_begin);            ignore_unused_variable_warning (it_end);            ignore_unused_variable_warning (it_rbegin);            ignore_unused_variable_warning (it_rend);        }    };    template<class I1, class I2>    struct IndexedBidirectional2DIteratorConcept {        typedef I1 subiterator1_type;        typedef I2 subiterator2_type;        void constraints () {            function_requires< BidirectionalIteratorConcept<subiterator1_type> >();            function_requires< BidirectionalIteratorConcept<subiterator2_type> >();            function_requires< Indexed2DIteratorConcept<subiterator1_type> >();            function_requires< Indexed2DIteratorConcept<subiterator2_type> >();        }    };    template<class I1, class I2>    struct Mutable_IndexedBidirectional2DIteratorConcept {        typedef I1 subiterator1_type;        typedef I2 subiterator2_type;        void constraints () {            function_requires< Mutable_BidirectionalIteratorConcept<subiterator1_type> >();            function_requires< Mutable_BidirectionalIteratorConcept<subiterator2_type> >();            function_requires< Indexed2DIteratorConcept<subiterator1_type> >();            function_requires< Indexed2DIteratorConcept<subiterator2_type> >();        }    };    template<class I1, class I2>    struct IndexedRandomAccess2DIteratorConcept {        typedef I1 subiterator1_type;        typedef I2 subiterator2_type;        void constraints () {            function_requires< RandomAccessIteratorConcept<subiterator1_type> >();            function_requires< RandomAccessIteratorConcept<subiterator2_type> >();            function_requires< Indexed2DIteratorConcept<subiterator1_type> >();            function_requires< Indexed2DIteratorConcept<subiterator2_type> >();        }    };    template<class I1, class I2>    struct Mutable_IndexedRandomAccess2DIteratorConcept {        typedef I1 subiterator1_type;        typedef I2 subiterator2_type;        void constraints () {            function_requires< Mutable_RandomAccessIteratorConcept<subiterator1_type> >();            function_requires< Mutable_RandomAccessIteratorConcept<subiterator2_type> >();            function_requires< Indexed2DIteratorConcept<subiterator1_type> >();            function_requires< Indexed2DIteratorConcept<subiterator2_type> >();        }    };    template<class C>    struct StorageArrayConcept {        typedef C container_type;        typedef typename C::size_type size_type;        typedef typename C::value_type value_type;        void constraints () {            function_requires< RandomAccessContainerConcept<container_type> >();            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 Mutable_StorageArrayConcept {        typedef C container_type;        typedef typename C::size_type size_type;        typedef typename C::value_type value_type;        typedef typename C::iterator iterator_type;        void constraints () {            function_requires< Mutable_RandomAccessContainerConcept<container_type> > ();            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;        void constraints () {            function_requires< ReversibleContainerConcept<container_type> > ();        }    };    template<class C>    struct Mutable_StorageSparseConcept {        typedef C container_type;        typedef typename C::size_type size_type;        typedef typename C::value_type value_type;        typedef typename C::iterator iterator_type;        void constraints () {            // NOTE - Not Mutable_ReversibleContainerConcept            function_requires< ReversibleContainerConcept<container_type> >();            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;        void constraints () {            function_requires< AssignableConcept<generator_type> >();            function_requires< ReversibleContainerConcept<generator_type> >();            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;        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;        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 ());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -