From 9cb405430ced75c63b7b7afa975c8b318ef4e398 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Tue, 21 Sep 2004 13:50:15 +0000 Subject: [PATCH] Simplified syntax Extended concept checks Fixed up failures hidden by FIXME Only compiles on conformant compilers [SVN r25310] --- include/boost/numeric/ublas/concepts.hpp | 203 +++++++++-------------- 1 file changed, 75 insertions(+), 128 deletions(-) diff --git a/include/boost/numeric/ublas/concepts.hpp b/include/boost/numeric/ublas/concepts.hpp index 8e26d3df..b98f1580 100644 --- a/include/boost/numeric/ublas/concepts.hpp +++ b/include/boost/numeric/ublas/concepts.hpp @@ -97,7 +97,7 @@ namespace boost { namespace numeric { namespace ublas { } }; - template + template::value_type> struct BidirectionalIteratorConcept { typedef I iterator_type; typedef T value_type; @@ -107,11 +107,10 @@ namespace boost { namespace numeric { namespace ublas { EqualityComparableConcept::constraints (iterator_type ()); DefaultConstructibleConcept::constraints (); iterator_type it = iterator_type (); - value_type t; - // Dereference - t = *it; + // Dereference - assume copy constructable value_type + const value_type t (*it); // Member access - // it->m; + // FIXME it->m; // Preincrement ++ it; // Postincrement @@ -124,7 +123,7 @@ namespace boost { namespace numeric { namespace ublas { } }; - template + template::value_type> struct MutableBidirectionalIteratorConcept { typedef I iterator_type; typedef T value_type; @@ -133,17 +132,13 @@ namespace boost { namespace numeric { namespace ublas { BidirectionalIteratorConcept::constraints (); iterator_type it = iterator_type (); value_type t = value_type (); -#ifdef BOOST_UBLAS_NON_STD // Dereference assignment *it = t; -#else - ignore_unused_variable_warning (it); -#endif ignore_unused_variable_warning (t); } }; - template + template::difference_type, class T = typename std::iterator_traits::value_type> struct RandomAccessIteratorConcept { typedef I iterator_type; typedef D difference_type; @@ -178,7 +173,7 @@ namespace boost { namespace numeric { namespace ublas { } }; - template + template::difference_type, class T = typename std::iterator_traits::value_type> struct MutableRandomAccessIteratorConcept { typedef I iterator_type; typedef D difference_type; @@ -204,8 +199,6 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { iterator_type it = iterator_type (); - // Function call - it (); // Index it.index (); } @@ -259,8 +252,6 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { iterator_type it = iterator_type (); - // Function call - it (); // Indices it.index1 (); it.index2 (); @@ -378,23 +369,11 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { ContainerConcept::constraints (); -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const container_type cc = container_type (); -#else - container_type c = container_type (); -#endif // Beginning of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const_reverse_iterator_type crit_begin (cc.rbegin ()); -#else - const_reverse_iterator_type crit_begin (c.rbegin ()); -#endif // End of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const_reverse_iterator_type crit_end (cc.rend ()); -#else - const_reverse_iterator_type crit_end (c.rend ()); -#endif ignore_unused_variable_warning (crit_end); ignore_unused_variable_warning (crit_begin); } @@ -453,7 +432,7 @@ namespace boost { namespace numeric { namespace ublas { }; template - struct StorageContainerConcept { + struct StorageArrayConcept { typedef C container_type; typedef typename C::size_type size_type; typedef typename C::value_type value_type; @@ -470,7 +449,7 @@ namespace boost { namespace numeric { namespace ublas { }; template - struct MutableStorageContainerConcept { + struct MutableStorageArrayConcept { typedef C container_type; typedef typename C::size_type size_type; typedef typename C::value_type value_type; @@ -491,7 +470,7 @@ namespace boost { namespace numeric { namespace ublas { }; template - struct SparseStorageContainerConcept { + struct StorageSparseConcept { typedef C container_type; typedef typename C::size_type size_type; @@ -501,7 +480,7 @@ namespace boost { namespace numeric { namespace ublas { }; template - struct MutableSparseStorageContainerConcept { + struct MutableStorageSparseConcept { typedef C container_type; typedef typename C::size_type size_type; typedef typename C::value_type value_type; @@ -514,10 +493,6 @@ namespace boost { namespace numeric { namespace ublas { iterator_type it = iterator_type (), it1 = iterator_type (), it2 = iterator_type (); // Insert c.insert (it, t); -#ifdef BOOST_UBLAS_NON_STD - // Range insert - c.insert (it, it1, it2); -#endif // Erase c.erase (it); // Range erase @@ -571,7 +546,7 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { DefaultConstructibleConcept::constraints (); - vector_type v = vector_type (); + const vector_type v = vector_type (); size_type n (0), i (0); value_type t; // Find (internal?) @@ -583,18 +558,10 @@ namespace boost { namespace numeric { namespace ublas { // Size n = v.size (); // Beginning of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const vector_type cv = vector_type (); const_reverse_iterator_type crit_begin (cv.rbegin ()); -#else - const_reverse_iterator_type crit_begin (v.rbegin ()); -#endif // End of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const_reverse_iterator_type crit_end (cv.rend ()); -#else - const_reverse_iterator_type crit_end (v.rend ()); -#endif // Element access t = v (i); ignore_unused_variable_warning (n); @@ -662,7 +629,7 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { DefaultConstructibleConcept::constraints (); - matrix_type m = matrix_type (); + const matrix_type m = matrix_type (); size_type n (0), i (0), j (0); value_type t; // Find (internal?) @@ -678,22 +645,12 @@ namespace boost { namespace numeric { namespace ublas { n = m.size1 (); n = m.size2 (); // Beginning of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const matrix_type cm = matrix_type (); const_reverse_iterator1_type crit1_begin (cm.rbegin1 ()); const_reverse_iterator2_type crit2_begin (cm.rbegin2 ()); -#else - const_reverse_iterator1_type crit1_begin (m.rbegin1 ()); - const_reverse_iterator2_type crit2_begin (m.rbegin2 ()); -#endif // End of reverse range -#ifndef BOOST_UBLAS_LWG_ISSUE_280 const_reverse_iterator1_type crit1_end (cm.rend1 ()); const_reverse_iterator2_type crit2_end (cm.rend2 ()); -#else - const_reverse_iterator1_type crit1_end (m.rend1 ()); - const_reverse_iterator2_type crit2_end (m.rend2 ()); -#endif // Element access t = m (i, j); ignore_unused_variable_warning (n); @@ -768,9 +725,13 @@ namespace boost { namespace numeric { namespace ublas { template struct VectorConcept { typedef V vector_type; + typedef typename V::size_type size_type; static void constraints () { VectorExpressionConcept::constraints (); + size_type n (0); + // Sizing constructor + vector_type v (n); } }; @@ -782,12 +743,11 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { MutableVectorExpressionConcept::constraints (); - VectorConcept::constraints (); size_type n (0); - // Sizing constructor - vector_type v = vector_type (n); value_type t = value_type (); size_type i (0); + // Sizing constructor + vector_type v (n); // Insert v.insert (i, t); // Erase @@ -802,9 +762,13 @@ namespace boost { namespace numeric { namespace ublas { template struct MatrixConcept { typedef M matrix_type; + typedef typename M::size_type size_type; static void constraints () { MatrixExpressionConcept::constraints (); + size_type n (0); + // Sizing constructor + matrix_type m (n, n); } }; @@ -816,12 +780,11 @@ namespace boost { namespace numeric { namespace ublas { static void constraints () { MutableMatrixExpressionConcept::constraints (); - MatrixConcept::constraints (); size_type n (0); - // Sizing constructor - matrix_type m = matrix_type (n, n); value_type t = value_type (); size_type i (0), j (0); + // Sizing constructor + matrix_type m (n, n); // Insert m.insert (i, j, t); // Erase @@ -830,6 +793,7 @@ namespace boost { namespace numeric { namespace ublas { m.clear (); // Resize m.resize (n, n); + m.resize (n, n, false); } }; @@ -846,7 +810,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (double) { return 0.; } -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> std::complex ZeroElement (std::complex) { @@ -857,7 +820,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (std::complex) { return std::complex (0.); } -#endif template<> vector ZeroElement (vector) { @@ -868,7 +830,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (vector) { return zero_vector (); } -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> vector > ZeroElement (vector >) { @@ -879,7 +840,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (vector >) { return zero_vector > (); } -#endif template<> matrix ZeroElement (matrix) { @@ -890,7 +850,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (matrix) { return zero_matrix (); } -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> matrix > ZeroElement (matrix >) { @@ -901,7 +860,6 @@ namespace boost { namespace numeric { namespace ublas { ZeroElement (matrix >) { return zero_matrix > (); } -#endif template T @@ -916,7 +874,6 @@ namespace boost { namespace numeric { namespace ublas { OneElement (double) { return 1.; } -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> std::complex OneElement (std::complex) { @@ -927,7 +884,6 @@ namespace boost { namespace numeric { namespace ublas { OneElement (std::complex) { return std::complex (1.); } -#endif template<> matrix OneElement (matrix) { @@ -938,7 +894,6 @@ namespace boost { namespace numeric { namespace ublas { OneElement (matrix) { return identity_matrix (); } -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) template<> matrix > OneElement (matrix >) { @@ -949,22 +904,21 @@ namespace boost { namespace numeric { namespace ublas { OneElement (matrix >) { return identity_matrix > (); } -#endif template bool operator == (const vector_expression &e1, const vector_expression &e2) { - typedef BOOST_UBLAS_TYPENAME promote_traits::promote_type value_type; - typedef BOOST_UBLAS_TYPENAME type_traits::real_type real_type; + typedef typename promote_traits::promote_type value_type; + typedef typename type_traits::real_type real_type; return norm_inf (e1 - e2) == real_type (); } template bool operator == (const matrix_expression &e1, const matrix_expression &e2) { - typedef BOOST_UBLAS_TYPENAME promote_traits::promote_type value_type; - typedef BOOST_UBLAS_TYPENAME type_traits::real_type real_type; + typedef typename promote_traits::promote_type value_type; + typedef typename type_traits::real_type real_type; return norm_inf (e1 - e2) == real_type (); } @@ -1093,62 +1047,61 @@ namespace boost { namespace numeric { namespace ublas { void concept_checks () { - // Storage + // Storage Array #if defined (INTERNAL) || defined (INTERNAL_STORAGE) - StorageContainerConcept >::constraints (); - MutableStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, double>::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, double>::constraints (); + StorageArrayConcept >::constraints (); + MutableStorageArrayConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); - StorageContainerConcept >::constraints (); - MutableStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, double>::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, double>::constraints (); + StorageArrayConcept >::constraints (); + MutableStorageArrayConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); - StorageContainerConcept >::constraints (); - MutableStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, double>::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, double>::constraints (); + StorageArrayConcept >::constraints (); + MutableStorageArrayConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); - StorageContainerConcept >::constraints (); - MutableStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, double>::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, double>::constraints (); + StorageArrayConcept >::constraints (); + MutableStorageArrayConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); IndexSetConcept::constraints (); - RandomAccessIteratorConcept::constraints (); + RandomAccessIteratorConcept::constraints (); IndexSetConcept::constraints (); - RandomAccessIteratorConcept::constraints (); + RandomAccessIteratorConcept::constraints (); IndexSetConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, std::size_t>::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); #endif - // Sparse Storage + // Storage Sparse #if defined (INTERNAL) || defined (INTERNAL_STORAGE_SPARSE) - SparseStorageContainerConcept >::constraints (); - MutableSparseStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, std::pair >::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, std::pair >::constraints (); + StorageSparseConcept >::constraints (); + MutableStorageSparseConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); + + StorageSparseConcept >::constraints (); + MutableStorageSparseConcept >::constraints (); + BidirectionalIteratorConcept::const_iterator>::constraints (); + // Not value_type mutable + BidirectionalIteratorConcept::iterator>::constraints (); #ifdef BOOST_UBLAS_DEPRACATED - SparseStorageContainerConcept >::constraints (); - MutableSparseStorageContainerConcept >::constraints (); - RandomAccessIteratorConcept::const_iterator, std::ptrdiff_t, std::size_t>::constraints (); - MutableRandomAccessIteratorConcept::iterator, std::ptrdiff_t, std::size_t>::constraints (); -#endif + StorageSparseConcept >::constraints (); + MutableStorageSparseConcept >::constraints (); + RandomAccessIteratorConcept::const_iterator>::constraints (); + MutableRandomAccessIteratorConcept::iterator>::constraints (); -#ifndef BOOST_UBLAS_NON_STD - SparseStorageContainerConcept >::constraints (); - MutableSparseStorageContainerConcept >::constraints (); - BidirectionalIteratorConcept::const_iterator, std::pair >::constraints (); - MutableBidirectionalIteratorConcept::iterator, std::pair >::constraints (); - - SparseStorageContainerConcept >::constraints (); - MutableSparseStorageContainerConcept >::constraints (); - BidirectionalIteratorConcept::const_iterator, std::size_t>::constraints (); - MutableBidirectionalIteratorConcept::iterator, std::size_t>::constraints (); + StorageSparseConcept >::constraints (); + MutableStorageSparseConcept >::constraints (); + BidirectionalIteratorConcept::const_iterator>::constraints (); + MutableBidirectionalIteratorConcept::iterator>::constraints (); #endif #endif @@ -1300,7 +1253,6 @@ namespace boost { namespace numeric { namespace ublas { IndexedRandomAccess1DIteratorConcept >::const_reverse_iterator>::constraints (); MutableIndexedRandomAccess1DIteratorConcept >::reverse_iterator>::constraints (); -#ifndef BOOST_UBLAS_ITERATOR_IS_INDEXABLE VectorExpressionConcept > >::constraints (); MutableVectorExpressionConcept > >::constraints (); IndexedRandomAccess1DIteratorConcept >::const_iterator>::constraints (); @@ -1321,7 +1273,6 @@ namespace boost { namespace numeric { namespace ublas { MutableIndexedRandomAccess1DIteratorConcept, vector >::iterator>::constraints (); IndexedRandomAccess1DIteratorConcept, vector >::const_reverse_iterator>::constraints (); MutableIndexedRandomAccess1DIteratorConcept, vector >::reverse_iterator>::constraints (); -#endif MatrixExpressionConcept > >::constraints (); MutableMatrixExpressionConcept > >::constraints (); @@ -1421,8 +1372,7 @@ namespace boost { namespace numeric { namespace ublas { symmetric_matrix::reverse_iterator2>::constraints (); MatrixExpressionConcept > >::constraints (); -//FIXME Know to fail -// MutableMatrixExpressionConcept > >::constraints (); + MutableMatrixExpressionConcept > >::constraints (); IndexedRandomAccess2DIteratorConcept >::const_iterator1, symmetric_adaptor >::const_iterator2>::constraints (); MutableIndexedRandomAccess2DIteratorConcept >::iterator1, @@ -1447,8 +1397,7 @@ namespace boost { namespace numeric { namespace ublas { hermitian_matrix::reverse_iterator2>::constraints (); MatrixExpressionConcept > >::constraints (); -//FIXME Know to fail -// MutableMatrixExpressionConcept > >::constraints (); + MutableMatrixExpressionConcept > >::constraints (); IndexedRandomAccess2DIteratorConcept >::const_iterator1, hermitian_adaptor >::const_iterator2>::constraints (); MutableIndexedRandomAccess2DIteratorConcept >::iterator1, @@ -1519,7 +1468,7 @@ namespace boost { namespace numeric { namespace ublas { #endif VectorExpressionConcept > >::constraints (); - // MutableVectorExpressionConcept > >::constraints (); + MutableVectorExpressionConcept > >::constraints (); IndexedRandomAccess1DIteratorConcept >::const_iterator>::constraints (); MutableIndexedRandomAccess1DIteratorConcept >::iterator>::constraints (); IndexedRandomAccess1DIteratorConcept >::const_reverse_iterator>::constraints (); @@ -1552,7 +1501,7 @@ namespace boost { namespace numeric { namespace ublas { // Matrix Expressions #if defined (INTERNAL) || defined (INTERNAL_MATRIX_EXPRESSION) MatrixExpressionConcept > >::constraints (); - // MutableMatrixExpressionConcept > >::constraints (); + MutableMatrixExpressionConcept > >::constraints (); IndexedRandomAccess2DIteratorConcept >::const_iterator1, matrix_reference >::const_iterator2>::constraints (); MutableIndexedRandomAccess2DIteratorConcept >::iterator1, @@ -1634,7 +1583,6 @@ namespace boost { namespace numeric { namespace ublas { VectorSpaceConcept >::constraints (); LinearOperatorConcept, matrix >::constraints (); -#if !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) AdditiveAbelianGroupConcept >::constraints (); CommutativeRingWithIdentityConcept >::constraints (); FieldConcept >::constraints (); @@ -1650,7 +1598,6 @@ namespace boost { namespace numeric { namespace ublas { RingWithIdentityConcept > >::constraints (0); VectorSpaceConcept, matrix > >::constraints (); LinearOperatorConcept, vector >, matrix > >::constraints (); -#endif #endif }