diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 7ef528c3..7109984d 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -1005,7 +1005,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename banded_matrix::const_value_type banded_matrix::zero_ (0); + typename banded_matrix::const_value_type banded_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME banded_matrix::const_value_type +#endif + (0); // Diagonal matrix class template @@ -2035,7 +2039,11 @@ namespace boost { namespace numeric { namespace ublas { template typename banded_adaptor::const_matrix_type banded_adaptor::nil_; template - typename banded_adaptor::const_value_type banded_adaptor::zero_ (0); + typename banded_adaptor::const_value_type banded_adaptor::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME banded_adaptor::const_value_type +#endif + (0); // Diagonal matrix adaptor class template diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp index 93d4af38..25ac9a64 100644 --- a/include/boost/numeric/ublas/config.hpp +++ b/include/boost/numeric/ublas/config.hpp @@ -38,6 +38,8 @@ #if BOOST_MSVC < 1300 // Cannot access private members from member class #define BOOST_UBLAS_NESTED_CLASS_DR45 +// static member data initialisers require = syntax +#define BOOST_UBLAS_STATIC_OLD_INIT #endif // Version 6.0 & 7.0 diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index 214d4e58..7c23de7f 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -2410,14 +2410,22 @@ namespace boost { namespace numeric { namespace ublas { private: size_type size1_; size_type size2_; - static value_type zero_; - static value_type one_; + static const value_type zero_; + static const value_type one_; }; template - typename identity_matrix::value_type identity_matrix::zero_ (0); + const typename identity_matrix::value_type identity_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME identity_matrix::value_type +#endif + (0); template - typename identity_matrix::value_type identity_matrix::one_ (1); + const typename identity_matrix::value_type identity_matrix::one_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME identity_matrix::value_type +#endif + (1); // Zero matrix class template @@ -2865,11 +2873,15 @@ namespace boost { namespace numeric { namespace ublas { private: size_type size1_; size_type size2_; - static value_type zero_; + static const value_type zero_; }; template - typename zero_matrix::value_type zero_matrix::zero_ (0); + const typename zero_matrix::value_type zero_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME zero_matrix::value_type +#endif + (0); // Scalar matrix class template diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index da362e5d..e59da1ba 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -1309,11 +1309,15 @@ namespace boost { namespace numeric { namespace ublas { size_type size2_; size_type non_zeros_; array_type data_; - static value_type zero_; + static const value_type zero_; }; template - typename sparse_matrix::value_type sparse_matrix::zero_ (0); + const typename sparse_matrix::value_type sparse_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME sparse_matrix::value_type +#endif + (0); // Array based sparse matrix class template @@ -2497,11 +2501,15 @@ namespace boost { namespace numeric { namespace ublas { size_type size2_; size_type non_zeros_; array_type data_; - static value_type zero_; + static const value_type zero_; }; template - typename sparse_vector_of_sparse_vector::value_type sparse_vector_of_sparse_vector::zero_ (0); + const typename sparse_vector_of_sparse_vector::value_type sparse_vector_of_sparse_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME sparse_vector_of_sparse_vector::value_type +#endif + (0); // Array based sparse matrix class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -3819,7 +3827,7 @@ namespace boost { namespace numeric { namespace ublas { index_array_type index1_data_; index_array_type index2_data_; value_array_type value_data_; - static value_type zero_; + static const value_type zero_; BOOST_UBLAS_INLINE static size_type zero_based (size_type k_based_index) { @@ -3837,7 +3845,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename compressed_matrix::value_type compressed_matrix::zero_ (0); + const typename compressed_matrix::value_type compressed_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME compressed_matrix::value_type +#endif + (0); // Array based sparse matrix class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -5130,7 +5142,7 @@ namespace boost { namespace numeric { namespace ublas { mutable index_array_type index1_data_; mutable index_array_type index2_data_; mutable value_array_type value_data_; - static value_type zero_; + static const value_type zero_; BOOST_UBLAS_INLINE static size_type zero_based (size_type k_based_index) { @@ -5148,7 +5160,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename coordinate_matrix::value_type coordinate_matrix::zero_ (0); + const typename coordinate_matrix::value_type coordinate_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME coordinate_matrix::value_type +#endif + (0); }}} diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index ea642f57..54205154 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -934,9 +934,17 @@ namespace boost { namespace numeric { namespace ublas { }; template - const typename triangular_matrix::value_type triangular_matrix::zero_ (0); + const typename triangular_matrix::value_type triangular_matrix::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME triangular_matrix::value_type +#endif + (0); template - const typename triangular_matrix::value_type triangular_matrix::one_ (1); + const typename triangular_matrix::value_type triangular_matrix::one_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME triangular_matrix::value_type +#endif + (1); // Triangular matrix adaptor class template @@ -1844,9 +1852,17 @@ namespace boost { namespace numeric { namespace ublas { template typename triangular_adaptor::const_matrix_type triangular_adaptor::nil_; template - const typename triangular_adaptor::value_type triangular_adaptor::zero_ (0); + const typename triangular_adaptor::value_type triangular_adaptor::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME triangular_adaptor::value_type +#endif + (0); template - const typename triangular_adaptor::value_type triangular_adaptor::one_ (1); + const typename triangular_adaptor::value_type triangular_adaptor::one_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME triangular_adaptor::value_type +#endif + (1); template struct matrix_vector_solve_traits { diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 6f7aa6c6..4a31acd7 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -850,9 +850,17 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename unit_vector::const_value_type unit_vector::zero_ (0); + typename unit_vector::const_value_type unit_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME unit_vector::const_value_type +#endif + (0); template - typename unit_vector::const_value_type unit_vector::one_ (1); + typename unit_vector::const_value_type unit_vector::one_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME unit_vector::const_value_type +#endif + (1); // Zero vector class template @@ -1061,7 +1069,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename zero_vector::const_value_type zero_vector::zero_ (0); + typename zero_vector::const_value_type zero_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME zero_vector::const_value_type +#endif + (0); // Scalar vector class template diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 1d2a993d..809c002a 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -33,16 +33,8 @@ namespace boost { namespace numeric { namespace ublas { private nonassignable { typedef const T const_value_type; public: - // Linear algebra identities - static const_value_type zero; - static const_value_type one; }; - template - typename expression_base::const_value_type expression_base::zero (0); - template - typename expression_base::const_value_type expression_base::one (1); - template struct scalar_expression: diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index 94c664f4..bbf4b26d 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -1217,11 +1217,15 @@ namespace boost { namespace numeric { namespace ublas { size_type size2_; size_type non_zeros_; array_type data_; - static value_type zero_; + static const value_type zero_; }; template - typename generalized_vector_of_vector::value_type generalized_vector_of_vector::zero_ (0); + const typename generalized_vector_of_vector::value_type generalized_vector_of_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME generalized_vector_of_vector::value_type +#endif + (0); }}} diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index be91e3df..2b7d76ed 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -717,11 +717,15 @@ namespace boost { namespace numeric { namespace ublas { size_type size_; size_type non_zeros_; array_type data_; - static value_type zero_; + static const value_type zero_; }; template - typename sparse_vector::value_type sparse_vector::zero_ (0); + const typename sparse_vector::value_type sparse_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME sparse_vector::value_type +#endif + (0); // Array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -1268,7 +1272,7 @@ namespace boost { namespace numeric { namespace ublas { size_type filled_; index_array_type index_data_; value_array_type value_data_; - static value_type zero_; + static const value_type zero_; BOOST_UBLAS_INLINE static size_type zero_based (size_type k_based_index) { @@ -1284,7 +1288,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename compressed_vector::value_type compressed_vector::zero_ (0); + const typename compressed_vector::value_type compressed_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME compressed_vector::value_type +#endif + (0); // Array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -1862,7 +1870,7 @@ namespace boost { namespace numeric { namespace ublas { mutable bool sorted_; mutable index_array_type index_data_; mutable value_array_type value_data_; - static value_type zero_; + static const value_type zero_; BOOST_UBLAS_INLINE static size_type zero_based (size_type k_based_index) { @@ -1878,7 +1886,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename coordinate_vector::value_type coordinate_vector::zero_ (0); + const typename coordinate_vector::value_type coordinate_vector::zero_ +#ifdef BOOST_UBLAS_STATIC_OLD_INIT + = BOOST_UBLAS_TYPENAME coordinate_vector::value_type +#endif + (0); }}}