diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake index 78d048d2c604669bab2cde67bf9fd3783f975283..a2150a190dafe7406af0fec6d3af86f89c0fbab0 100644 --- a/cmake/modules/CheckCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -1,21 +1,15 @@ # # Module that checks for supported C++11 (former C++0x) features. # -# Sets the follwing variable: +# Sets the follwing variables: # # HAVE_NULLPTR True if nullptr is available -# HAVE_ARRAY True if header <array> and fill() are available -# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported # HAS_ATTRIBUTE_UNUSED True if attribute unused is supported # HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported # HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported # HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant -# HAVE_STATIC_ASSERT True if static_assert is available -# HAVE_VARIADIC_TEMPLATES True if variadic templates are supprt -# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported -# HAVE_RVALUE_REFERENCES True if rvalue references are supported -# HAVE_STD_CONDITIONAL True if std::conditional is supported -# HAVE_INITIALIZER_LIST True if initializer list is supported +# HAVE_CONSTEXPR True if constexpr is supported +# HAVE_KEYWORD_FINAL True if final is supported. include(CMakePushCheckState) cmake_push_check_state() @@ -67,25 +61,12 @@ include(CheckIncludeFile) include(CheckIncludeFileCXX) if(NOT DISABLE_TR1_HEADERS) -# array and fill -check_cxx_source_compiles(" - #include <array> - - int main(void) - { - std::array<int,2> a; - a.fill(9); - return 0; - } -" HAVE_ARRAY -) - # Search for some tr1 headers -foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits) +foreach(_HEADER type_traits tr1/type_traits) string(REPLACE "/" "_" _HEADER_VAR ${_HEADER}) string(TOUPPER ${_HEADER_VAR} _HEADER_VAR ) check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}") -endforeach(_HEADER tuple tr1/tuple tr1/type_traits) +endforeach() # Check for hash support check_include_file_cxx("functional" "HAVE_FUNCTIONAL") @@ -198,132 +179,6 @@ check_cxx_source_compiles(" " HAS_ATTRIBUTE_DEPRECATED_MSG ) -# static assert -check_cxx_source_compiles(" - int main(void) - { - static_assert(true,\"MSG\"); - return 0; - } -" HAVE_STATIC_ASSERT -) - -# variadic template support -check_cxx_source_compiles(" - #include <cassert> - - template<typename... T> - int addints(T... x); - - int add_ints() - { - return 0; - } - - template<typename T1, typename... T> - int add_ints(T1 t1, T... t) - { - return t1 + add_ints(t...); - } - - int main(void) - { - assert( 5 == add_ints(9,3,-5,-2) ); - return 0; - } -" HAVE_VARIADIC_TEMPLATES -) - -# SFINAE on variadic template constructors within template classes -check_cxx_source_compiles(" - #include <functional> - - template<typename... U> - struct A - { - template<typename... T, - typename = typename std::enable_if<(sizeof...(T) < 2)>::type - > - A(T... t) - : i(1) - {} - - template<typename... T, - typename = typename std::enable_if<(sizeof...(T) >= 2)>::type, - typename = void - > - A(T... t) - : i(-1) - {} - - A() - : i(1) - {} - - int i; - }; - - int main(void) - { - return (A<int>().i + A<int>(2).i + A<int>(\"foo\",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1); - } -" HAVE_VARIADIC_CONSTRUCTOR_SFINAE -) - -# rvalue references -check_cxx_source_compiles(" - #include <cassert> - #include <utility> - int foo(int&& x) { return 1; } - int foo(const int& x) { return -1; } - - template<typename T> - int forward(T&& x) - { - return foo(std::forward<T>(x)); - } - - int main(void) - { - int i = 0; - assert( forward(i) + forward(int(2)) == 0); - return 0; - } -" HAVE_RVALUE_REFERENCES -) - -# std::conditional -check_cxx_source_compiles(" - #include <type_traits> - - int main(void){ - return std::conditional<true,std::integral_constant<int,0>,void>::type::value; - } -" HAVE_STD_CONDITIONAL -) - -# initializer list -check_cxx_source_compiles(" - #include <initializer_list> - #include <vector> - - struct A - { - A(std::initializer_list<int> il) - : vec(il) - {} - - std::vector<int> vec; - }; - - int main(void) - { - A a{1,3,4,5}; - return 0; - } -" HAVE_INITIALIZER_LIST -) - # constexpr check_cxx_source_compiles(" constexpr int foo() diff --git a/cmake/modules/CheckSharedPtr.cmake b/cmake/modules/CheckSharedPtr.cmake deleted file mode 100644 index 1a962c2f6869f3eb4969c49e61209edba0258048..0000000000000000000000000000000000000000 --- a/cmake/modules/CheckSharedPtr.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# Module checks for shared_ptr support. -# -# Sets the following variables: -# -# HAVE_BOOST_MAKE_SHARED_HPP: True if boost/make_shared.hpp is found -# SHARED_PTR_NAMESPACE: Namespace of shared_ptr (e.g. std) -# SHARED_PTR_HEADER: The name of header file supplying shared_ptr -# -# check if make_shared works -macro(check_make_shared) - include(CheckIncludeFileCXX) - - if(SHARED_PTR_NAMESPACE EQUAL "boost") - check_include_file_cxx("boost/make_shared.hpp" HAVE_BOOST_MAKE_SHARED_HPP) - endif(SHARED_PTR_NAMESPACE EQUAL "boost") - - check_include_file_cxx("boost/shared_ptr.hpp" HAVE_BOOST_SHARED_PTR_HPP) - - check_cxx_source_compiles(" - #if defined(HAVE_MEMORY) - # include <memory> - #endif - #if defined(HAVE_TR1_MEMORY) - # include <tr1/memory> - #endif - #if defined(HAVE_BOOST_SHARED_PTR_HPP) && defined(HAVE_BOOST_MAKE_SHARED_HPP) - # include <boost/shared_ptr.hpp> - # include <boost/make_shared.hpp> - #endif - - int main(void) - { - ${SHARED_PTR_NAMESPACE}::make_shared<int>(3); - return 0; - } - " HAVE_MAKE_SHARED) -endmacro(check_make_shared) - -# check location of shared_ptr header file and the necessary namespace -include(CheckCXXSourceCompiles) - -# search namespace -foreach(SHARED_PTR_NAMESPACE_ "std" "tr1" "std::tr1" "boost") - check_cxx_source_compiles(" - #include <memory> - #include <string> - - using ${SHARED_PTR_NAMESPACE_}::shared_ptr; - using namespace std; - - int main(void) - { - shared_ptr<string> test_ptr(new string(\"test string\")); - return 0; - }" - SHARED_PTR_NAMESPACE_FOUND) - - if(SHARED_PTR_NAMESPACE_FOUND) - #search header name - foreach(SHARED_PTR_HEADER_ "<memory>" "<tr1/memory>" "<boost/shared_ptr.hpp>") - check_cxx_source_compiles(" - # include ${SHARED_PTR_HEADER_} - #include <string> - - using ${SHARED_PTR_NAMESPACE_}::shared_ptr; - using namespace std; - - int main(void) - { - shared_ptr<string> test_ptr(new string(\"test string\")); - return 0; - }" - SHARED_PTR_HEADER_FOUND) - - if(SHARED_PTR_HEADER_FOUND) - # save result - set(SHARED_PTR_NAMESPACE ${SHARED_PTR_NAMESPACE_}) - set(SHARED_PTR_HEADER ${SHARED_PTR_HEADER_}) - check_make_shared() - return() - endif(SHARED_PTR_HEADER_FOUND) - endforeach(SHARED_PTR_HEADER_) - endif(SHARED_PTR_NAMESPACE_FOUND) -endforeach(SHARED_PTR_NAMESPACE_) diff --git a/cmake/modules/DuneCommonMacros.cmake b/cmake/modules/DuneCommonMacros.cmake index 49dbb13127cee4c98dbfaa21311377f9a8dca070..34ac14aa7c221a9137bfd019191f83997109755f 100644 --- a/cmake/modules/DuneCommonMacros.cmake +++ b/cmake/modules/DuneCommonMacros.cmake @@ -3,12 +3,11 @@ # all dependent modules # # Specifically it configure the DUNE debug streams and -# tests whether std::shared_ptr, LAPACK and BLAS are available. +# tests whether LAPACK and BLAS are available. # include(DuneStreams) dune_set_minimal_debug_level() -include(CheckSharedPtr) if(Fortran_Works) # search for lapack find_package(LAPACK) diff --git a/cmake/modules/Makefile.am b/cmake/modules/Makefile.am index 917612ce2536cc5e0356cd9ad33785005c5befaa..a78a1271ec811c43b6d24265f9af05856b847ed3 100644 --- a/cmake/modules/Makefile.am +++ b/cmake/modules/Makefile.am @@ -4,7 +4,6 @@ MODULES = \ AddParMETISFlags.cmake \ AddUMFPackFlags.cmake \ CheckCXX11Features.cmake \ - CheckSharedPtr.cmake \ DuneBoost.cmake \ DuneCMakePackageConfigHelpers.cmake \ DuneCommonMacros.cmake \ diff --git a/config.h.cmake b/config.h.cmake index 2ce105eaf936398d11f8a8e7b0495f6c11d6023b..c75535141e8e76fe748a540074b104d1f5cb5e65 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -26,30 +26,18 @@ /* does the compiler support __attribute__((unused))? */ #cmakedefine HAS_ATTRIBUTE_UNUSED 1 -/* Define to 1 if the header <array> from C++11 is available and supports array::fill */ -#cmakedefine HAVE_ARRAY 1 - /* Define if you have a BLAS library. */ #cmakedefine HAVE_BLAS 1 /* Define to ENABLE_BOOST if the Boost library is available */ #cmakedefine HAVE_DUNE_BOOST ENABLE_BOOST -/* Define to 1 if you have <boost/make_shared.hpp>. */ -#cmakedefine HAVE_BOOST_MAKE_SHARED_HPP 1 - -/* Define to 1 if you have the <boost/shared_ptr.hpp> header file. */ -#cmakedefine HAVE_BOOST_SHARED_PTR_HPP 1 - /* does the compiler support abi::__cxa_demangle */ #cmakedefine HAVE_CXA_DEMANGLE 1 /* Define if you have LAPACK library. */ #cmakedefine HAVE_LAPACK 1 -/* Define to 1 if SHARED_PTR_NAMESPACE::make_shared is usable. */ -#cmakedefine HAVE_MAKE_SHARED 1 - /* Define to 1 if you have the <malloc.h> header file. */ // Not used! #cmakedefine01 HAVE_MALLOC_H @@ -68,9 +56,6 @@ /* Define to 1 if nullptr is supported */ #cmakedefine HAVE_NULLPTR 1 -/* Define to 1 if static_assert is supported */ -#cmakedefine HAVE_STATIC_ASSERT 1 - /* Define to 1 if you have the <stdint.h> header file. */ #cmakedefine HAVE_STDINT_H 1 @@ -80,9 +65,6 @@ /* Define to 1 if the std::tr1::hash template from TR1 is available. */ #cmakedefine HAVE_TR1_HASH 1 -/* Define to 1 if you have the <tr1/tuple> header file. */ -#cmakedefine HAVE_TR1_TUPLE 1 - /* Define to 1 if you have the <tr1/type_traits> header file. */ #cmakedefine HAVE_TR1_TYPE_TRAITS 1 @@ -94,15 +76,9 @@ /* Define to 1 if the std::hash template from C++11 is available. */ #cmakedefine HAVE_STD_HASH 1 -/* Define to 1 if you have the <tuple> header file. */ -#cmakedefine HAVE_TUPLE 1 - /* Define to 1 if you have the <type_traits> header file. */ #cmakedefine HAVE_TYPE_TRAITS 1 -/* Define to 1 if you have the <type_traits> header file. */ -#cmakedefine HAVE_STD_CONDITIONAL 1 - /* Define to 1 if the MPI2 Standard is supported */ #cmakedefine MPI_2 1 @@ -134,24 +110,6 @@ /* end private */ -/* The header in which SHARED_PTR can be found */ -#cmakedefine SHARED_PTR_HEADER ${SHARED_PTR_HEADER} - -/* The namespace in which SHARED_PTR can be found */ -#cmakedefine SHARED_PTR_NAMESPACE ${SHARED_PTR_NAMESPACE} - -/* Define to 1 if variadic templates are supported */ -#cmakedefine HAVE_VARIADIC_TEMPLATES 1 - -/* Define to 1 if SFINAE on variadic template constructors is fully supported */ -#cmakedefine HAVE_VARIADIC_CONSTRUCTOR_SFINAE 1 - -/* Define to 1 if rvalue references are supported */ -#cmakedefine HAVE_RVALUE_REFERENCES 1 - -/* Define to 1 if initializer list is supported */ -#cmakedefine HAVE_INITIALIZER_LIST 1 - /* Define to 1 if C++11 constexpr is supported */ #cmakedefine HAVE_CONSTEXPR 1 diff --git a/doc/buildsystem/buildsystem.tex b/doc/buildsystem/buildsystem.tex index 599aae9817dc384438a7e2da8870f696e459e00c..66d606f71cd3be88e94da63d97fde5fe4e205609 100644 --- a/doc/buildsystem/buildsystem.tex +++ b/doc/buildsystem/buildsystem.tex @@ -1100,12 +1100,13 @@ available and which dimension has been selected (if applicable). This information can then be used at compile-time to include header files or code that depend on optional packages. -As an example, the macro \lstinline!HAVE_ARRAY!\ can be used to compile -code using C++11 arrays as in +As an example, the macro \lstinline!HAVE_GMP!\ can be used to compile +code using the GNU Multiple Precision Arithmetic Library (GMP) as in \begin{lstlisting}[basicstyle=\ttfamily\scriptsize] -#ifdef HAVE_ARRAY -#include <array> -std::array <int, 5> a = {1, 2, 3}; +#ifdef HAVE_GMP +#include <gmp.h> +mpz_t d; +mpz_init_set_str(d, "14159265", 10); #endif \end{lstlisting} diff --git a/dune/common/array.hh b/dune/common/array.hh index 42e6ed1edf07a689db634af8f1bd47c6ea27058a..52bf2110294b6c144500a2f6ff4996666081c5ec 100644 --- a/dune/common/array.hh +++ b/dune/common/array.hh @@ -8,18 +8,8 @@ \brief Fallback implementation of the std::array class (a static array) */ -#include <iostream> -#include <iomanip> -#include <string> - -// Include system implementation of array class if present -#ifdef HAVE_ARRAY #include <array> -#else -#include <algorithm> -#endif - -#include "deprecated.hh" +#include <iostream> namespace Dune { @@ -28,131 +18,8 @@ namespace Dune @{ */ -#ifdef HAVE_ARRAY + // pull in default implementation using std::array; -#else - - /** \brief Simple fixed size array class. This replaces std::array, - * if that is not available. - * - */ - template<class T, size_t N> - class array { - public: - - //! Remember the storage type - typedef T value_type; - - /** \brief Reference to an object */ - typedef value_type& reference; - - /** \brief Const reference to an object */ - typedef const value_type& const_reference; - - /** \brief Iterator type */ - typedef value_type* iterator; - - /** \brief Const iterator type */ - typedef const value_type* const_iterator; - - /** \brief Type used for array indices */ - typedef std::size_t size_type; - - /** \brief Difference type */ - typedef std::ptrdiff_t difference_type; - - /** \brief Reverse iterator type */ - typedef std::reverse_iterator<iterator> reverse_iterator; - - /** \brief Const reverse iterator type */ - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - /** \brief Return array size */ - size_type size() const {return N;} - - //! Assign value to all entries - array<T,N>& operator= (const T& t) - { - fill(t); - return (*this); - } - - //! \brief Assign value to all entries (according to C++0x the fill method is to be prefered) - void assign(const T& t) DUNE_DEPRECATED - { - fill(t); - } - - //! \brief Assign value to all entries (according to C++0x the fill method is to be prefered) - void fill(const T& t) - { - for (size_type i=0; i<N; i++) a[i]=t; - } - - //! Component access - reference operator[] (size_type i) - { - return a[i]; - } - - //! Const component access - const_reference operator[] (size_type i) const - { - return a[i]; - } - - iterator begin () - { - return a; - } - - const_iterator begin () const - { - return a; - } - - iterator end () - { - return a + N; - } - - const_iterator end () const - { - return a + N; - } - - T a[(N > 0) ? N : 1]; - }; - - - - // Comparison Operators (see [lib.container.requirements]) - // ------------------------------------------------------- - - template< class T, size_t N > - inline bool operator< ( const array< T, N > &a, const array< T, N > &b ) - { - return std::lexicographical_compare( a.begin(), a.end(), b.begin(), b.end() ); - } - - template< class T, size_t N > - inline bool operator> ( const array< T, N > &a, const array< T, N > &b ) - { - return b < a; - } - - template< class T, size_t N > - inline bool operator<= ( const array< T, N > &a, const array< T, N > &b ) - { - return !(a > b); - } - - template< class T, size_t N > - inline bool operator>= ( const array< T, N > &a, const array< T, N > &b ) - { - return !(a < b); - } -#endif //! Output operator for array template < class T, size_t N > @@ -262,11 +129,7 @@ namespace Dune { array<T,n> r; r.fill(t); -#if HAVE_RVALUE_REFERENCES return std::move(r); -#else - return r; -#endif } /** @} */ diff --git a/dune/common/debugallocator.hh b/dune/common/debugallocator.hh index fd50ab0445ef799e3153301b20168252dedb17dc..db5c0a40b15922fcd50f9914105ca5226ff18766 100644 --- a/dune/common/debugallocator.hh +++ b/dune/common/debugallocator.hh @@ -277,15 +277,14 @@ namespace Dune { ::new((void*)p)T(val); } -#if ( HAVE_VARIADIC_TEMPLATES && HAVE_RVALUE_REFERENCES ) || DOXYGEN + //! construct an object of type T from variadic parameters - //! \note works only with newer C++ compilers template<typename ... _Args> void construct(pointer p, _Args&&... __args) { ::new((void *)p)T(std::forward<_Args>(__args) ...); } -#endif + //! destroy an object of type T (i.e. call the destructor) void destroy(pointer p) { diff --git a/dune/common/densematrix.hh b/dune/common/densematrix.hh index 6d7d6f306fc38cbe76b5271eba7361da4b00ca34..4cd46617ddd04ea9b578da130fba71613d886d37 100644 --- a/dune/common/densematrix.hh +++ b/dune/common/densematrix.hh @@ -12,7 +12,6 @@ #include <dune/common/exceptions.hh> #include <dune/common/fvector.hh> #include <dune/common/precision.hh> -#include <dune/common/static_assert.hh> #include <dune/common/classname.hh> #include <dune/common/math.hh> #include <dune/common/unused.hh> @@ -142,7 +141,7 @@ namespace Dune { static void apply ( M &m, const T &t ) { - dune_static_assert( (Conversion< const T, const M >::exists), "No template specialization of DenseMatrixAssigner found" ); + static_assert( (Conversion< const T, const M >::exists), "No template specialization of DenseMatrixAssigner found" ); m = static_cast< const M & >( t ); } }; diff --git a/dune/common/documentation.hh b/dune/common/documentation.hh index e783a9c44ec0283a4d6c6838be075ebc9c9dc9f9..071ac2c591bb2e3520769a66fd05b8cd23ab1f5d 100644 --- a/dune/common/documentation.hh +++ b/dune/common/documentation.hh @@ -19,8 +19,8 @@ namespace Dune { * // Traits class that determines some property for some other type T * template<class T> * class SomeTraits { - * dune_static_assert(AlwaysFalse<T>::value, - * "Sorry, SomeTraits must be specialized for all types"); + * static_assert(AlwaysFalse<T>::value, + * "Sorry, SomeTraits must be specialized for all types"); * public: * // The type of some property of T * typedef ImplementationDefined type; diff --git a/dune/common/dynmatrix.hh b/dune/common/dynmatrix.hh index 96a8fef11bab87dff6ff5e0467c88a74b4191aac..b23ee398f8fc35627c2c4feea07fd394cc07ab1c 100644 --- a/dune/common/dynmatrix.hh +++ b/dune/common/dynmatrix.hh @@ -11,7 +11,6 @@ #include <dune/common/exceptions.hh> #include <dune/common/dynvector.hh> #include <dune/common/densematrix.hh> -#include <dune/common/static_assert.hh> namespace Dune { diff --git a/dune/common/fmatrix.hh b/dune/common/fmatrix.hh index 95190a0b55ee8d4f7413bd0c6356c6e530e1a3d2..8db1b577148f2028aa6c3daa0e110624ac94e145 100644 --- a/dune/common/fmatrix.hh +++ b/dune/common/fmatrix.hh @@ -13,7 +13,6 @@ #include <dune/common/fvector.hh> #include <dune/common/densematrix.hh> #include <dune/common/precision.hh> -#include <dune/common/static_assert.hh> #include <dune/common/std/constexpr.hh> namespace Dune diff --git a/dune/common/forloop.hh b/dune/common/forloop.hh index eb6b265b79c7b77d81656250707d9e77172f3ed4..330ca572b7c7b9e91e373fce219ddfccbbc7376f 100644 --- a/dune/common/forloop.hh +++ b/dune/common/forloop.hh @@ -8,8 +8,6 @@ * \brief A static for loop for template meta-programming */ -#include <dune/common/static_assert.hh> - namespace Dune { @@ -21,7 +19,7 @@ namespace Dune class GenericForLoop : public Operation< Value< first >, GenericForLoop< Operation, Value, first+1, last > > { - dune_static_assert( (first <= last), "GenericForLoop: first > last" ); + static_assert( (first <= last), "GenericForLoop: first > last" ); }; template< template< class, class > class Operation, template< int > class Value, int last > @@ -221,7 +219,7 @@ namespace Dune class ForLoop : public GenericForLoop< ForLoopHelper::Apply, Operation, first, last > { - dune_static_assert( (first <= last), "ForLoop: first > last" ); + static_assert( (first <= last), "ForLoop: first > last" ); }; } diff --git a/dune/common/fvector.hh b/dune/common/fvector.hh index 710de61fd4053f9adbcd695f3f274125e025c968..9e0098d99274218345e92071791e342de1cf7ea2 100644 --- a/dune/common/fvector.hh +++ b/dune/common/fvector.hh @@ -10,7 +10,7 @@ #include <complex> #include <cstring> #include <utility> -#include<initializer_list> +#include <initializer_list> #include <dune/common/std/constexpr.hh> @@ -18,7 +18,6 @@ #include "exceptions.hh" #include "array.hh" #include "densevector.hh" -#include "static_assert.hh" #include "unused.hh" namespace Dune { @@ -105,20 +104,8 @@ namespace Dune { //! Constructor making default-initialized vector FieldVector() - // Use C++11 unified initialization if available - tends to generate - // fastest code -#if HAVE_INITIALIZER_LIST : _data{} {} -#else - { - // fall back to library approach - this gives faster code than array placement - // new. Apart from that, placement new may create problems if K is a complex - // type. In that case, the default constructor of the _data elements has already - // been called and may have allocated memory. - std::fill(_data.begin(),_data.end(),K()); - } -#endif //! Constructor making vector with identical coordinates explicit FieldVector (const K& t) @@ -164,7 +151,7 @@ namespace Dune { template<class K1, int SIZE1> explicit FieldVector (const FieldVector<K1,SIZE1> & x) { - dune_static_assert(SIZE1 == SIZE, "FieldVector in constructor has wrong size"); + static_assert(SIZE1 == SIZE, "FieldVector in constructor has wrong size"); for (size_type i = 0; i<SIZE; i++) _data[i] = x[i]; } @@ -247,7 +234,7 @@ namespace Dune { template<class C> FieldVector (const DenseVector<C> & x) { - dune_static_assert(((bool)IsFieldVectorSizeCorrect<C,1>::value), "FieldVectors do not match in dimension!"); + static_assert(((bool)IsFieldVectorSizeCorrect<C,1>::value), "FieldVectors do not match in dimension!"); assert(x.size() == 1); _data = x[0]; } diff --git a/dune/common/gcd.hh b/dune/common/gcd.hh index b685fa07a6baa0ce6de96ac7cbff9abb7b3e2e31..30a69a02b4483774b28ff0a9f34483ff59f34735 100644 --- a/dune/common/gcd.hh +++ b/dune/common/gcd.hh @@ -3,7 +3,6 @@ #ifndef DUNE_GCD_HH #define DUNE_GCD_HH -#include "static_assert.hh" namespace Dune { /** @@ -32,8 +31,8 @@ namespace Dune */ static void conceptCheck() { - dune_static_assert(b<a, "b<a must hold!"); - dune_static_assert(0<b, "b must be positive"); + static_assert(b<a, "b<a must hold!"); + static_assert(0<b, "b must be positive"); } diff --git a/dune/common/hash.hh b/dune/common/hash.hh index 251276eb142b85b557c98219296650bfe369e1c3..a0468d1f894d062bf6690dc0226a156456c8d6cd 100644 --- a/dune/common/hash.hh +++ b/dune/common/hash.hh @@ -4,7 +4,6 @@ #define DUNE_COMMON_HASH_HH #include <dune/common/typetraits.hh> -#include <dune/common/static_assert.hh> #if HAVE_STD_HASH #include <functional> @@ -359,7 +358,7 @@ namespace Dune { template<typename typeof_size_t, typename T> void operator()(typeof_size_t& seed, const T& arg) const { - dune_static_assert(sizeof(typeof_size_t)==8, "hash_combiner::operator() instantiated with nonmatching type and size"); + static_assert(sizeof(typeof_size_t)==8, "hash_combiner::operator() instantiated with nonmatching type and size"); // The following algorithm for combining two 64-bit hash values is inspired by a similar // function in CityHash (http://cityhash.googlecode.com/svn-history/r2/trunk/src/city.h), @@ -396,7 +395,7 @@ namespace Dune { template<typename typeof_size_t, typename T> void operator()(typeof_size_t& seed, const T& arg) const { - dune_static_assert(sizeof(typeof_size_t)==4, "hash_combiner::operator() instantiated with nonmatching type and size"); + static_assert(sizeof(typeof_size_t)==4, "hash_combiner::operator() instantiated with nonmatching type and size"); // The default algorithm above requires a 64-bit std::size_t. The following algorithm is a // 32-bit compatible fallback, again inspired by CityHash and MurmurHash diff --git a/dune/common/lcm.hh b/dune/common/lcm.hh index 5ef9dc72b6fc604ae72721f7dcd3041f392059ca..cf8c5d340281729905f96360254bd066a8be52ee 100644 --- a/dune/common/lcm.hh +++ b/dune/common/lcm.hh @@ -7,7 +7,6 @@ * \brief Statically compute the least common multiple of two integers */ -#include <dune/common/static_assert.hh> #include <dune/common/gcd.hh> namespace Dune @@ -31,8 +30,8 @@ namespace Dune { static void conceptCheck() { - dune_static_assert(0<m, "m must be positive!"); - dune_static_assert(0<n, "n must be positive!"); + static_assert(0<m, "m must be positive!"); + static_assert(0<n, "n must be positive!"); } /** * @brief The least common multiple of the template parameters diff --git a/dune/common/mallocallocator.hh b/dune/common/mallocallocator.hh index 8b27c073708fe07fb7984babf3c1ca1cf3925807..65f6764ec35c4db25f86ca73ac2e24197c9babfc 100644 --- a/dune/common/mallocallocator.hh +++ b/dune/common/mallocallocator.hh @@ -82,15 +82,14 @@ namespace Dune { ::new((void*)p)T(val); } -#if ( HAVE_VARIADIC_TEMPLATES && HAVE_RVALUE_REFERENCES ) || DOXYGEN + //! construct an object of type T from variadic parameters - //! \note works only with newer C++ compilers template<typename ... _Args> void construct(pointer p, _Args&&... __args) { ::new((void *)p)T(std::forward<_Args>(__args) ...); } -#endif + //! destroy an object of type T (i.e. call the destructor) void destroy(pointer p) { diff --git a/dune/common/parallel/remoteindices.hh b/dune/common/parallel/remoteindices.hh index 91d885e4ccff070e88bb95bbea0bc79809b86d06..97227e95fde261179758dfe6595a54a425b63028 100644 --- a/dune/common/parallel/remoteindices.hh +++ b/dune/common/parallel/remoteindices.hh @@ -9,7 +9,6 @@ #include <dune/common/exceptions.hh> #include <dune/common/poolallocator.hh> #include <dune/common/sllist.hh> -#include <dune/common/static_assert.hh> #include <dune/common/stdstreams.hh> #include <map> #include <set> @@ -1606,9 +1605,9 @@ namespace Dune { template<typename T, typename A, bool mode> inline void RemoteIndexListModifier<T,A,mode>::insert(const RemoteIndex& index) throw(InvalidPosition) { - dune_static_assert(!mode,"Not allowed if the mode indicates that new indices" - "might be added to the underlying index set. Use " - "insert(const RemoteIndex&, const GlobalIndex&) instead"); + static_assert(!mode,"Not allowed if the mode indicates that new indices" + "might be added to the underlying index set. Use " + "insert(const RemoteIndex&, const GlobalIndex&) instead"); #ifdef DUNE_ISTL_WITH_CHECKING if(!first_ && index.localIndexPair().global()<last_) @@ -1629,7 +1628,7 @@ namespace Dune { template<typename T, typename A, bool mode> inline void RemoteIndexListModifier<T,A,mode>::insert(const RemoteIndex& index, const GlobalIndex& global) throw(InvalidPosition) { - dune_static_assert(mode,"Not allowed if the mode indicates that no new indices" + static_assert(mode,"Not allowed if the mode indicates that no new indices" "might be added to the underlying index set. Use " "insert(const RemoteIndex&) instead"); #ifdef DUNE_ISTL_WITH_CHECKING diff --git a/dune/common/poolallocator.hh b/dune/common/poolallocator.hh index 16fd3a71904ee371a9077773ae5a61afbf077e3b..8aa49746286fb640c8490f6e5ad11351948bfbb5 100644 --- a/dune/common/poolallocator.hh +++ b/dune/common/poolallocator.hh @@ -9,7 +9,6 @@ */ #include "alignment.hh" -#include "static_assert.hh" #include "lcm.hh" #include <typeinfo> #include <iostream> @@ -448,14 +447,14 @@ namespace Dune inline Pool<T,S>::Pool() : head_(0), chunks_(0) //, allocated_(0) { - dune_static_assert(sizeof(T)<=unionSize, "Library Error: type T is too big"); - dune_static_assert(sizeof(Reference)<=unionSize, "Library Error: type of referene is too big"); - dune_static_assert(unionSize<=alignedSize, "Library Error: alignedSize too small"); - dune_static_assert(sizeof(T)<=chunkSize, "Library Error: chunkSize must be able to hold at least one value"); - dune_static_assert(sizeof(Reference)<=chunkSize, "Library Error: chunkSize must be able to hold at least one reference"); - dune_static_assert((chunkSize - (alignment - 1)) % alignment == 0, "Library Error: compiler cannot calculate!"); - dune_static_assert(elements>=1, "Library Error: we need to hold at least one element!"); - dune_static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned elements must fit into chuck!"); + static_assert(sizeof(T)<=unionSize, "Library Error: type T is too big"); + static_assert(sizeof(Reference)<=unionSize, "Library Error: type of referene is too big"); + static_assert(unionSize<=alignedSize, "Library Error: alignedSize too small"); + static_assert(sizeof(T)<=chunkSize, "Library Error: chunkSize must be able to hold at least one value"); + static_assert(sizeof(Reference)<=chunkSize, "Library Error: chunkSize must be able to hold at least one reference"); + static_assert((chunkSize - (alignment - 1)) % alignment == 0, "Library Error: compiler cannot calculate!"); + static_assert(elements>=1, "Library Error: we need to hold at least one element!"); + static_assert(elements*alignedSize<=chunkSize, "Library Error: aligned elements must fit into chuck!"); /* std::cout<<"s= "<<S<<" : T: "<<sizeof(T)<<" Reference: "<<sizeof(Reference)<<" union: "<<unionSize<<" alignment: "<<alignment<< "aligned: "<<alignedSize<<" chunk: "<< chunkSize<<" elements: "<<elements<<std::endl;*/ } diff --git a/dune/common/propertymap.hh b/dune/common/propertymap.hh index 49aa92dd3be2511f14651366adc287b426f6b2ab..3f7e917c80736b2a41e4e8cce39e9c6cb1114194 100644 --- a/dune/common/propertymap.hh +++ b/dune/common/propertymap.hh @@ -7,7 +7,6 @@ #include <cstddef> #include <iterator> -#include "static_assert.hh" #include "typetraits.hh" namespace Dune @@ -93,7 +92,7 @@ namespace Dune put(const RAPropertyMapHelper<Reference,PropertyMap>& pmap, const Key& key, const Value& value) { - dune_static_assert((Conversion<typename PropertyMap::Category,WritablePropertyMapTag> + static_assert((Conversion<typename PropertyMap::Category,WritablePropertyMapTag> ::exists), "WritablePropertyMapTag required!"); static_cast<const PropertyMap&>(pmap)[key] = value; } diff --git a/dune/common/shared_ptr.hh b/dune/common/shared_ptr.hh index e5f6e5424c2d9cf8b0fc9a89e094a74a31c5ad40..6db28a39cfeb873ed25b58cd7a61d822da40d4e2 100644 --- a/dune/common/shared_ptr.hh +++ b/dune/common/shared_ptr.hh @@ -5,14 +5,7 @@ #ifndef DUNE_SHARED_PTR_HH #define DUNE_SHARED_PTR_HH -#if defined SHARED_PTR_HEADER -# include SHARED_PTR_HEADER -#endif -#if defined HAVE_BOOST_SHARED_PTR_HPP -#if defined HAVE_BOOST_MAKE_SHARED_HPP -# include <boost/make_shared.hpp> -#endif -#endif +#include <memory> #include <dune/common/nullptr.hh> #include <dune/common/typetraits.hh> @@ -24,437 +17,9 @@ */ namespace Dune { - // A shared_ptr implementation has been found if SHARED_PTR_NAMESPACE is set at all -#ifdef SHARED_PTR_NAMESPACE - using SHARED_PTR_NAMESPACE :: shared_ptr; -#else - - /** @addtogroup Common - * - * @{ - */ - - /** @brief The object we reference. */ - class SharedCount - { - template<class T1> - friend class shared_ptr; - protected: - /** @brief The number of references. */ - int count_; - /** @brief Constructor from existing Pointer. */ - SharedCount() : count_(1) {} - /** @brief Copy constructor with type conversion. */ - SharedCount(const SharedCount& rep) - : count_(rep.count_) {} - - /** @brief Destructor, deletes element_type* rep_. */ - virtual ~SharedCount() {}; - - }; - /** - * @brief A reference counting smart pointer. - * - * It is designed such that it is usable within a std::vector. - * The contained object is destroyed only if there are no more - * references to it. - */ - template<class T> - class shared_ptr - { - template<class T1> friend class shared_ptr; - - public: - /** - * @brief The data type we are a pointer for. - * - * This has to have a parameterless constructor. - */ - typedef T element_type; - - /** - * @brief Constructs a new smart pointer and allocates the referenced Object. - */ - inline shared_ptr(); - - inline shared_ptr(nullptr_t null); - - /** - * @brief Constructs a new smart pointer from a preallocated Object. - * - * \param pointer Raw pointer to the shared data - * - * note: the object must be allocated on the heap and after handing the pointer to - * shared_ptr the ownership of the pointer is also handed to the shared_ptr. - */ - template<class T1> - inline shared_ptr(T1 * pointer); - - - /** - * @brief Constructs a new smart pointer from a preallocated Object. - * - * \tparam Deleter This class must by copyconstructable, the copy constructor must not throw an exception - * and it must implement void operator() (T*) const - * - * \param pointer Raw pointer to the shared data - * \param deleter A copy of this deleter is stored - * - * note: the object must be allocated on the heap and after handing the pointer to - * shared_ptr the ownership of the pointer is also handed to the shared_ptr. - */ - template<class T1, class Deleter> - inline shared_ptr(T1 * pointer, Deleter deleter); - - /** - * @brief Copy constructor. - * @param pointer The object to copy. - */ - template<class T1> - inline shared_ptr(const shared_ptr<T1>& pointer); - - /** - * @brief Copy constructor. - * @param pointer The object to copy. - */ - inline shared_ptr(const shared_ptr& pointer); - - /** - * @brief Destructor. - */ - inline ~shared_ptr(); - - /** \brief Assignment operator */ - template<class T1> - inline shared_ptr& operator=(const shared_ptr<T1>& pointer); - - /** \brief Assignment operator */ - inline shared_ptr& operator=(const shared_ptr& pointer); - - /** \brief Dereference as object */ - inline element_type& operator*(); - - /** \brief Dereference as pointer */ - inline element_type* operator->(); - - /** \brief Dereference as const object */ - inline const element_type& operator*() const; - - /** \brief Dereference as const pointer */ - inline const element_type* operator->() const; - - /** \brief Access to the raw pointer, if you really want it */ - element_type* get() const { - return rep_; - } - - /** \brief Checks if shared_ptr manages an object, i.e. whether get() != 0. */ - operator bool() const { - return count_ != 0 && rep_ != 0; - } - - /** \brief Swap content of this shared_ptr and another */ - inline void swap(shared_ptr& other); - - /** \brief Decrease the reference count by one and free the memory if the - reference count has reached 0 - */ - inline void reset(); - - /** \brief Detach shared pointer and set it anew for the given pointer */ - template<class T1> - inline void reset(T1* pointer); - - //** \brief Same as shared_ptr(pointer,deleter).swap(*this) - template<class T1, class Deleter> - inline void reset(T1* pointer, Deleter deleter); - - /** \brief The number of shared_ptrs pointing to the object we point to */ - int use_count() const; - - private: - /** \brief Assignment operator */ - template<class T1> - inline shared_ptr& assign(const shared_ptr<T1>& pointer); - /** @brief Adds call to deleter to SharedCount. */ - template<class Deleter> - class SharedCountImpl : - public SharedCount - { - template<class T1> - friend class shared_ptr; - /** @brief Constructor from existing Pointer with custom deleter. */ - SharedCountImpl(T* elem,const Deleter& deleter) : - SharedCount(), - deleter_(deleter), - rep_(elem) - {} - /** @brief Copy constructor with type conversion. */ - SharedCountImpl(const SharedCountImpl& rep) - : SharedCount(rep), deleter_(rep.deleter_), rep_(rep.rep_) {} - /** @brief Destructor, deletes element_type* rep_ using deleter. */ - ~SharedCountImpl() - { deleter_(rep_); } - - // store a copy of the deleter - Deleter deleter_; - T* rep_; - }; - - /** \brief A default deleter that just calls delete */ - struct DefaultDeleter - { - void operator() (element_type* p) const - { delete p; } - }; - - - SharedCount *count_; - T *rep_; - - // Needed for the implicit conversion to "bool" - typedef T* *__unspecified_bool_type; - - public: - /** \brief Implicit conversion to "bool" */ - operator __unspecified_bool_type() const // never throws - { - return rep_ == 0 ? 0 : &shared_ptr::rep_; - } - - }; - - template<class T> - template<class T1> - inline shared_ptr<T>::shared_ptr(T1 * p) - { - rep_ = p; - count_ = new SharedCountImpl<DefaultDeleter>(p, DefaultDeleter()); - } - - template<class T> - inline shared_ptr<T>::shared_ptr(nullptr_t) - { - rep_ = 0; - count_ = 0; - } - - template<class T> - template<class T1, class Deleter> - inline shared_ptr<T>::shared_ptr(T1 * p, Deleter deleter) - { - rep_ = p; - count_ = new SharedCountImpl<Deleter>(p, deleter); - } - - template<class T> - inline shared_ptr<T>::shared_ptr() - { - rep_ = 0; - count_=0; - } - - template<class T> - template<class T1> - inline shared_ptr<T>::shared_ptr(const shared_ptr<T1>& other) - : count_(other.count_), rep_(other.rep_) - { - if (rep_) - ++(count_->count_); - } - - template<class T> - inline shared_ptr<T>::shared_ptr(const shared_ptr& other) - : count_(other.count_), rep_(other.rep_) - { - if (rep_) - ++(count_->count_); - } - - template<class T> - template<class T1> - inline shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr<T1>& other) - { - return assign(other); - } - - template<class T> - inline shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr& other) - { - return assign(other); - } - - template<class T> - template<class T1> - inline shared_ptr<T>& shared_ptr<T>::assign(const shared_ptr<T1>& other) - { - if (other.count_) - (other.count_->count_)++; - - if(rep_!=0 && --(count_->count_)<=0) { - delete count_; - } - - rep_ = other.rep_; - count_ = other.count_; - return *this; - } - - template<class T> - inline shared_ptr<T>::~shared_ptr() - { - if(rep_!=0 && --(count_->count_)==0) { - delete count_; - rep_=0; - } - } - - template<class T> - inline T& shared_ptr<T>::operator*() - { - return *(rep_); - } - - template<class T> - inline T *shared_ptr<T>::operator->() - { - return rep_; - } - - template<class T> - inline const T& shared_ptr<T>::operator*() const - { - return *(rep_); - } - - template<class T> - inline const T *shared_ptr<T>::operator->() const - { - return rep_; - } - - template<class T> - inline int shared_ptr<T>::use_count() const - { - return count_->count_; - } - - template<class T> - inline void shared_ptr<T>::swap(shared_ptr<T>& other) - { - SharedCount* dummy = count_; - count_=other.count_; - other.count_ = dummy; - T* tdummy=rep_; - rep_ = other.rep_; - other.rep_ = tdummy; - } - - template<class T> - inline void shared_ptr<T>::reset() - { - shared_ptr<T>().swap(*this); - } - - template<class T> - template<class T1> - inline void shared_ptr<T>::reset(T1* pointer) - { - shared_ptr<T>(pointer).swap(*this); - } - - template<class T> - template<class T1, class Deleter> - inline void shared_ptr<T>::reset(T1* pointer, Deleter deleter) - { - shared_ptr<T>(pointer, deleter).swap(*this); - } - - /** @} */ -#endif // #ifdef SHARED_PTR_NAMESPACE - - - // C++0x and Boost have a make_shared implementation, TR1 does not. - // Unfortunately, TR1 gets picked over Boost if present. - // Moreover, boost::make_shared() only exists for (remotely) recent versions of Boost. -#if HAVE_MAKE_SHARED -#ifdef SHARED_PTR_NAMESPACE - using SHARED_PTR_NAMESPACE :: make_shared; -#endif -#else - - template<typename T> - shared_ptr<T> make_shared() - { - return shared_ptr<T>(new T()); - } - - template<typename T, typename Arg1> - shared_ptr<T> make_shared(const Arg1& arg1) - { - return shared_ptr<T>(new T(arg1)); - } - - template<typename T, typename Arg1, typename Arg2> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2) - { - return shared_ptr<T>(new T(arg1,arg2)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3) - { - return shared_ptr<T>(new T(arg1,arg2,arg3)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, - typename Arg5> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4,arg5)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, - typename Arg5, typename Arg6> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4,arg5,arg6)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, - typename Arg5, typename Arg6, typename Arg7> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, - typename Arg5, typename Arg6, typename Arg7, typename Arg8> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7, const Arg8& arg8) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)); - } - - template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, - typename Arg5, typename Arg6, typename Arg7, typename Arg8, typename Arg9> - shared_ptr<T> make_shared(const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, - const Arg5& arg5, const Arg6& arg6, const Arg7& arg7, const Arg8& arg8, - const Arg9& arg9) - { - return shared_ptr<T>(new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)); - } - -#endif // custom make_shared + // pull in default implementations + using std::shared_ptr; + using std::make_shared; /** @brief implements the Deleter concept of shared_ptr without deleting anything diff --git a/dune/common/static_assert.hh b/dune/common/static_assert.hh index 510cf8c79fe29fd7ef0e80a18bc4a2169a53e83c..f91982bf477ed221a54d4970daaa8d1cf8837a31 100644 --- a/dune/common/static_assert.hh +++ b/dune/common/static_assert.hh @@ -3,6 +3,8 @@ #ifndef DUNE_STATIC_ASSERT_HH #define DUNE_STATIC_ASSERT_HH +#warning This header and the macro dune_static_assert are deprecated, use static_assert instead. + /** \file * \brief Fallback implementation of the C++0x static_assert feature */ @@ -13,27 +15,6 @@ * @{ */ -#if not HAVE_STATIC_ASSERT -// Taken from BOOST -// -// Helper macro CPPMAGIC_JOIN: -// The following piece of macro magic joins the two -// arguments together, even when one of the arguments is -// itself a macro (see 16.3.1 in C++ standard). The key -// is that macro expansion of macro arguments does not -// occur in CPPMAGIC_DO_JOIN2 but does in CPPMAGIC_DO_JOIN. -// -#define CPPMAGIC_JOIN( X, Y ) CPPMAGIC_DO_JOIN( X, Y ) -#define CPPMAGIC_DO_JOIN( X, Y ) CPPMAGIC_DO_JOIN2(X,Y) -#define CPPMAGIC_DO_JOIN2( X, Y ) X ## Y - -template <bool x> struct static_assert_failure; - -template <> struct static_assert_failure<true> { }; - -template<int x> struct static_assert_test {}; -#endif - /** \brief Helper template so that compilation fails if condition is not true. @@ -70,17 +51,11 @@ template<int x> struct static_assert_test {}; This is because dune_static_assert is a preprocessor macro</li> </ol> + \deprecated Use static_assert from C++11 instead. */ -#if HAVE_STATIC_ASSERT #define dune_static_assert(COND,MSG) \ static_assert(COND,MSG) -#else -#define dune_static_assert(COND,MSG) \ - typedef static_assert_test< \ - sizeof(static_assert_failure< (bool)( COND )>)\ - > CPPMAGIC_JOIN (dune_static_assert_typedef_, __LINE__) -#endif namespace Dune { /** diff --git a/dune/common/test/CMakeLists.txt b/dune/common/test/CMakeLists.txt index 6fac67f7f00c41ca03749ef6c9f846cae8ee2d4c..b4fdf746ff57963d406885dcf61006c7286a42e0 100644 --- a/dune/common/test/CMakeLists.txt +++ b/dune/common/test/CMakeLists.txt @@ -27,9 +27,7 @@ set(TESTS parametertreetest poolallocatortest shared_ptrtest_config - shared_ptrtest_dune singletontest - static_assert_test streamtest testfassign1 testfassign2 @@ -38,8 +36,6 @@ set(TESTS testfconstruct testfloatcmp tuplestest_config - tuplestest_dune - tuplestest_tr1 tupleutilitytest utilitytest) @@ -62,7 +58,6 @@ set(COMPILEFAILTESTS check_fvector_size_fail2 genericiterator_compile_fail nullptr-test-fail - static_assert_test_fail testfconstruct_fail1 testfconstruct_fail2) @@ -154,12 +149,8 @@ target_link_libraries("pathtest" "dunecommon") add_executable("poolallocatortest" poolallocatortest.cc) add_executable("shared_ptrtest_config" shared_ptrtest.cc) -add_executable("shared_ptrtest_dune" shared_ptrtest.cc) -set_target_properties(shared_ptrtest_dune PROPERTIES COMPILE_FLAGS "-DDISABLE_CONFIGURED_SHARED_PTR") add_executable("singletontest" singletontest.cc) add_executable("sllisttest" EXCLUDE_FROM_ALL sllisttest.cc) -add_executable("static_assert_test" EXCLUDE_FROM_ALL static_assert_test.cc) -add_executable("static_assert_test_fail" EXCLUDE_FROM_ALL static_assert_test_fail.cc) add_executable("streamtest" streamtest.cc) target_link_libraries("streamtest" "dunecommon") @@ -224,10 +215,6 @@ add_executable("testfconstruct_fail2" EXCLUDE_FROM_ALL testfconstruct.cc) set_target_properties(testfconstruct_fail2 PROPERTIES COMPILE_FLAGS "-DFVSIZE=5") target_link_libraries(testfconstruct_fail2 "dunecommon") add_executable("tuplestest_config" tuplestest.cc) -add_executable("tuplestest_dune" tuplestest.cc) -set_target_properties(tuplestest_dune PROPERTIES COMPILE_FLAGS "-DDISABLE_TR1_TUPLE -DDISABLE_STD_TUPLE") -add_executable("tuplestest_tr1" tuplestest.cc) -set_target_properties(tuplestest_tr1 PROPERTIES COMPILE_FLAGS "-DDISABLE_STD_TUPLE") add_executable("tupleutilitytest" tupleutilitytest.cc) add_executable("utilitytest" utilitytest.cc) diff --git a/dune/common/test/Makefile.am b/dune/common/test/Makefile.am index a5218adc3c407627c90215baa25145fe572fd716..2e785fd02292ba9b2be343416d557dc063e01536 100644 --- a/dune/common/test/Makefile.am +++ b/dune/common/test/Makefile.am @@ -29,9 +29,7 @@ TESTPROGS = \ parametertreetest \ poolallocatortest \ shared_ptrtest_config \ - shared_ptrtest_dune \ singletontest \ - static_assert_test \ streamtest \ testdebugallocator \ testdebugallocator_fail1 \ @@ -51,9 +49,7 @@ TESTPROGS = \ testfassign_fail6 \ testfconstruct \ testfloatcmp \ - tuplestest_dune \ tuplestest_std \ - tuplestest_tr1 \ tupleutilitytest \ typetraitstest \ utilitytest @@ -66,7 +62,6 @@ COMPILE_XFAIL_TESTS = \ check_fvector_size_fail2 \ genericiterator_compile_fail \ nullptr-test-fail \ - static_assert_test_fail \ testfconstruct_fail1 \ testfconstruct_fail2 @@ -187,19 +182,12 @@ poolallocatortest_SOURCES = poolallocatortest.cc shared_ptrtest_config_SOURCES = shared_ptrtest.cc -shared_ptrtest_dune_SOURCES = shared_ptrtest.cc -shared_ptrtest_dune_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_CONFIGURED_SHARED_PTR - singletontest_SOURCES = singletontest.cc sllisttest_SOURCES = sllisttest.cc sourcescheck_NOSOURCES = timing.cc -static_assert_test_SOURCES = static_assert_test.cc -static_assert_test_fail_SOURCES = static_assert_test_fail.cc - streamtest_SOURCES = streamtest.cc testdebugallocator_SOURCES = testdebugallocator.cc @@ -261,16 +249,8 @@ testfconstruct_fail2_CPPFLAGS = $(AM_CPPFLAGS) -DFVSIZE=5 testfloatcmp_SOURCES = testfloatcmp.cc -tuplestest_dune_SOURCES = tuplestest.cc -tuplestest_dune_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_TR1_TUPLE -DDISABLE_STD_TUPLE - tuplestest_std_SOURCES = tuplestest.cc -tuplestest_tr1_SOURCES = tuplestest.cc -tuplestest_tr1_CPPFLAGS = $(AM_CPPFLAGS) \ - -DDISABLE_STD_TUPLE - tupleutilitytest_SOURCES = tupleutilitytest.cc typetraitstest_SOURCES = typetraitstest.cc diff --git a/dune/common/test/fvectortest.cc b/dune/common/test/fvectortest.cc index b1dd3d0f5f7748b17f8396a0eb00cf3cc20997a8..b0fe17ca134c7976056e2c81ecf4a3b0d8931769 100644 --- a/dune/common/test/fvectortest.cc +++ b/dune/common/test/fvectortest.cc @@ -6,7 +6,6 @@ #include <dune/common/fvector.hh> #include <dune/common/exceptions.hh> #include <dune/common/typetraits.hh> -#include <dune/common/static_assert.hh> #include <dune/common/classname.hh> #include <iostream> #include <complex> @@ -33,16 +32,16 @@ struct FieldVectorMainTest std::cout << __func__ << "\t ( " << className(v) << " )" << std::endl; // test traits - dune_static_assert( + static_assert( ( Dune::is_same< typename Dune::FieldTraits< FieldVector<ft,d> >::field_type, ft >::value ), "FieldTraits<FieldVector> yields wrong field_type" ); - dune_static_assert( + static_assert( ( Dune::is_same< typename Dune::FieldTraits<ft>::real_type, rt >::value ), "FieldTraits<field_type> yields wrong real_type" ); - dune_static_assert( + static_assert( ( Dune::is_same< typename Dune::FieldTraits< FieldVector<ft,d> >::real_type, rt >::value ), "FieldTraits<FieldVector> yields wrong real_type" @@ -211,7 +210,7 @@ struct DotProductTest typedef std::complex<rt> ct; const rt myEps(1e-6); - dune_static_assert( + static_assert( ( Dune::is_same< typename Dune::FieldTraits<rt>::real_type, rt>::value ), "DotProductTest requires real data type as template parameter!" ); @@ -224,8 +223,8 @@ struct DotProductTest const bool isRealOne = Dune::is_same<typename Dune::FieldTraits<rt>::field_type,typename Dune::FieldTraits<rt>::real_type>::value; const bool isRealIVec = Dune::is_same<typename Dune::FieldTraits<ct>::field_type,typename Dune::FieldTraits<ct>::real_type> ::value; - dune_static_assert(isRealOne,"1-vector expected to be real"); - dune_static_assert(!isRealIVec,"i-vector expected to be complex"); + static_assert(isRealOne,"1-vector expected to be real"); + static_assert(!isRealIVec,"i-vector expected to be complex"); ct result = ct(); ct length = ct(d); diff --git a/dune/common/test/gcdlcmtest.cc b/dune/common/test/gcdlcmtest.cc index f1f85407ef6bd9b8c6218bd6bd2ce6d2661be0c4..31d478f5c84aaa78f2ff9a8bc0ac335f21b82ed2 100644 --- a/dune/common/test/gcdlcmtest.cc +++ b/dune/common/test/gcdlcmtest.cc @@ -8,14 +8,17 @@ #include <dune/common/gcd.hh> #include <dune/common/lcm.hh> -#include <dune/common/static_assert.hh> void test() { - dune_static_assert((Dune::Gcd<2*2*2*5*5*5*11, 2*2*5*13>::value == 2*2*5), "gcd not working properly"); - dune_static_assert((Dune::Lcm<11,3>::value == 33), "lcm not working properly"); - dune_static_assert((Dune::Lcm<18,15>::value == 18*15/3), "lcm not working properly"); - dune_static_assert((Dune::Lcm<10800,Dune::Lcm<36000,7680>::value>::value==1728000), "lcm not working properly"); + static_assert((Dune::Gcd<2*2*2*5*5*5*11, 2*2*5*13>::value == 2*2*5), + "gcd not working properly"); + static_assert((Dune::Lcm<11,3>::value == 33), + "lcm not working properly"); + static_assert((Dune::Lcm<18,15>::value == 18*15/3), + "lcm not working properly"); + static_assert((Dune::Lcm<10800,Dune::Lcm<36000,7680>::value>::value==1728000), + "lcm not working properly"); } int main() diff --git a/dune/common/test/shared_ptrtest.cc b/dune/common/test/shared_ptrtest.cc index d06edb7ea9e211876384b9f381984c8ca00fa1fe..5630487cbad585e8c529c39cb76caa69b6091bce 100644 --- a/dune/common/test/shared_ptrtest.cc +++ b/dune/common/test/shared_ptrtest.cc @@ -12,11 +12,6 @@ #include "config.h" #endif -#if defined(DISABLE_CONFIGURED_SHARED_PTR) && defined(SHARED_PTR_NAMESPACE) -#undef SHARED_PTR_NAMESPACE -#undef HAVE_MAKE_SHARED -#endif - #include <dune/common/classname.hh> #include <dune/common/shared_ptr.hh> @@ -157,7 +152,7 @@ int main(){ assert(bar); // test constructor from nullptr -#if defined(SHARED_PTR_HEADER) && !defined(HAVE_NULLPTR) +#ifndef HAVE_NULLPTR #error Construction of shared_ptr from a nullptr will not work as compiler #error does not support the latter. shared_ptr<double> bar_null=shared_ptr<double>(); diff --git a/dune/common/test/static_assert_test.cc b/dune/common/test/static_assert_test.cc deleted file mode 100644 index e7ac0b2db6117579fd58010b1783e1d778081b13..0000000000000000000000000000000000000000 --- a/dune/common/test/static_assert_test.cc +++ /dev/null @@ -1,12 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <dune/common/static_assert.hh> - -int main() -{ - dune_static_assert(true, "OK"); - return 0; -} diff --git a/dune/common/test/static_assert_test_fail.cc b/dune/common/test/static_assert_test_fail.cc deleted file mode 100644 index a3a6520742183b728eddb463da87acaf7a361311..0000000000000000000000000000000000000000 --- a/dune/common/test/static_assert_test_fail.cc +++ /dev/null @@ -1,12 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include <dune/common/static_assert.hh> - -int main() -{ - dune_static_assert(false, "FAIL"); - return 0; -} diff --git a/dune/common/test/tuplestest.cc b/dune/common/test/tuplestest.cc index acc7172bafad9fac02d9ae5ed0f87988022dc1f9..b6bff9d15b02936d018de8901dfd655ed881d0e3 100644 --- a/dune/common/test/tuplestest.cc +++ b/dune/common/test/tuplestest.cc @@ -12,14 +12,6 @@ #include "config.h" #endif -#if defined(DISABLE_TR1_TUPLE) && defined(HAVE_TR1_TUPLE) -#undef HAVE_TR1_TUPLE -#endif - -#if defined(DISABLE_STD_TUPLE) && defined(HAVE_TUPLE) -#undef HAVE_TUPLE -#endif - #include <cassert> #include <cstdlib> #include <iostream> @@ -62,7 +54,7 @@ int iteratorTupleTest() Tuple tuple_(v.begin(), v.begin(), v.end()); - dune_static_assert(tuple_size<Tuple>::value==3, "The tuple size should be 3!");; + static_assert(tuple_size<Tuple>::value==3, "The tuple size should be 3!");; int ret=0; diff --git a/dune/common/test/tupleutilitytest.cc b/dune/common/test/tupleutilitytest.cc index 6ee3e4fdd5fb2cc4c9c2a73d0e5010b15e996cc9..74381b102f4acc24f0d015e774bea8c15d78fb6a 100644 --- a/dune/common/test/tupleutilitytest.cc +++ b/dune/common/test/tupleutilitytest.cc @@ -7,7 +7,6 @@ #include <cstddef> -#include <dune/common/static_assert.hh> #include <dune/common/tuples.hh> #include <dune/common/tupleutility.hh> @@ -16,15 +15,12 @@ // check FirstTypeIndex // typedef Dune::tuple<int, unsigned, double> MyTuple; -dune_static_assert((Dune::FirstTypeIndex<MyTuple, int>::value == 0), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); -dune_static_assert((Dune::FirstTypeIndex<MyTuple, unsigned>::value == 1), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); -dune_static_assert((Dune::FirstTypeIndex<MyTuple, double>::value == 2), - "FirstTypeIndex finds the wrong index for double in " - "MyTuple!"); +static_assert((Dune::FirstTypeIndex<MyTuple, int>::value == 0), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); +static_assert((Dune::FirstTypeIndex<MyTuple, unsigned>::value == 1), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); +static_assert((Dune::FirstTypeIndex<MyTuple, double>::value == 2), + "FirstTypeIndex finds the wrong index for double in MyTuple!"); @@ -33,8 +29,8 @@ dune_static_assert((Dune::FirstTypeIndex<MyTuple, double>::value == 2), // check PushBackTuple typedef Dune::PushBackTuple<MyTuple, char>::type MyTupleAppended1; typedef Dune::tuple<int, unsigned, double, char> MyTupleAppended2; -dune_static_assert((Dune::is_same<MyTupleAppended1, MyTupleAppended2>::value), - "PushBackTuple failed!"); +static_assert((Dune::is_same<MyTupleAppended1, MyTupleAppended2>::value), + "PushBackTuple failed!"); @@ -43,8 +39,8 @@ dune_static_assert((Dune::is_same<MyTupleAppended1, MyTupleAppended2>::value), // check PushFrontTuple typedef Dune::PushFrontTuple<MyTuple, char>::type MyTuplePrepended1; typedef Dune::tuple<char, int, unsigned, double> MyTuplePrepended2; -dune_static_assert((Dune::is_same<MyTuplePrepended1, MyTuplePrepended2>::value), - "PushFrontTuple failed!"); +static_assert((Dune::is_same<MyTuplePrepended1, MyTuplePrepended2>::value), + "PushFrontTuple failed!"); @@ -53,8 +49,8 @@ dune_static_assert((Dune::is_same<MyTuplePrepended1, MyTuplePrepended2>::value), // check JoinTuples typedef Dune::JoinTuples<MyTuple, MyTuple>::type MyTupleMyTuple1; typedef Dune::tuple<int, unsigned, double, int, unsigned, double> MyTupleMyTuple2; -dune_static_assert((Dune::is_same<MyTupleMyTuple1, MyTupleMyTuple2>::value), - "JoinTuples failed!"); +static_assert((Dune::is_same<MyTupleMyTuple1, MyTupleMyTuple2>::value), + "JoinTuples failed!"); @@ -65,8 +61,8 @@ typedef Dune::tuple<char, float> MyTuple2; typedef Dune::tuple<MyTuple, MyTuple2> MyTupleTuple; typedef Dune::FlattenTuple<MyTupleTuple>::type MyTupleTupleFlat1; typedef Dune::tuple<int, unsigned, double, char, float> MyTupleTupleFlat2; -dune_static_assert((Dune::is_same<MyTupleTupleFlat1, MyTupleTupleFlat2>::value), - "FlattenTuples failed!"); +static_assert((Dune::is_same<MyTupleTupleFlat1, MyTupleTupleFlat2>::value), + "FlattenTuples failed!"); @@ -143,8 +139,8 @@ typedef Dune::tuple< Dune::integral_constant<int, 3>, Dune::integral_constant<int, 5>, Dune::integral_constant<int, 7> > Primes2; -dune_static_assert((Dune::is_same<Primes1, Primes2>::value), - "ReduceTuple failed in primes-tmp!"); +static_assert((Dune::is_same<Primes1, Primes2>::value), + "ReduceTuple failed in primes-tmp!"); int main() {} diff --git a/dune/common/test/typetraitstest.cc b/dune/common/test/typetraitstest.cc index a2d05bc7a6eb600a019246a14d4d899eb3763a0f..f344cb26a50c267b39cf94a5509f781350106945 100644 --- a/dune/common/test/typetraitstest.cc +++ b/dune/common/test/typetraitstest.cc @@ -24,9 +24,7 @@ int main() { // Test TypeTraits::isReference assert( not Dune::TypeTraits<int>::isReference ); assert( Dune::TypeTraits<int&>::isReference ); -#if HAVE_RVALUE_REFERENCES assert( not Dune::TypeTraits<int&&>::isReference ); -#endif // Test TypeTraits::PointeeType assert( (Dune::is_same<Dune::Empty, Dune::TypeTraits<int>::PointeeType>::value) ); @@ -48,9 +46,7 @@ int main() { // Test is_reference assert( not Dune::is_lvalue_reference<int>::value ); assert( Dune::is_lvalue_reference<int&>::value ); -#if HAVE_RVALUE_REFERENCES assert( not Dune::is_lvalue_reference<int&&>::value ); -#endif // Test remove_pointer // Note: when the argument T is not a pointer, TypeTraits::PointeeType returns Dune::Empty, @@ -64,9 +60,7 @@ int main() { // Test remove_reference assert( (Dune::is_same<int, Dune::remove_reference<int>::type>::value) ); assert( (Dune::is_same<int, Dune::remove_reference<int&>::type>::value) ); -#if HAVE_RVALUE_REFERENCES assert( (Dune::is_same<int, Dune::remove_reference<int&&>::type>::value) ); -#endif return 0; } diff --git a/dune/common/test/utilitytest.cc b/dune/common/test/utilitytest.cc index 3016704b83a2d6135629f5af34870d8d91132317..57a4c146f63ab34652c12e6e5a2479f6b0113a6b 100644 --- a/dune/common/test/utilitytest.cc +++ b/dune/common/test/utilitytest.cc @@ -5,7 +5,6 @@ #include "config.h" #endif -#include <dune/common/static_assert.hh> #include <dune/common/tuples.hh> #include <dune/common/typetraits.hh> #include <dune/common/tupleutility.hh> @@ -62,7 +61,7 @@ int main(int, char**) typedef Dune::tuple<int&,char&,long&,char&> RefTuple1; typedef Dune::tuple<int*,char*,long*,char*> PointerTuple1; - dune_static_assert((Dune::is_same<PointerTuple1, + static_assert((Dune::is_same<PointerTuple1, Dune::ForEachType<Dune::AddPtrTypeEvaluator, RefTuple1>::Type>::value), "RefTuple1 with added pointers should be the same as " diff --git a/dune/common/tuples.hh b/dune/common/tuples.hh index abb3625abf3519a9c9ea05548ba03579c1a5d88b..49cd33ce8618e069fe7ca7597dd11d044cd0b256 100644 --- a/dune/common/tuples.hh +++ b/dune/common/tuples.hh @@ -7,14 +7,9 @@ #include <iostream> #include "typetraits.hh" -#include "static_assert.hh" #include "unused.hh" -#ifdef HAVE_TUPLE #include <tuple> -#elif defined HAVE_TR1_TUPLE -#include <tr1/tuple> -#endif namespace Dune { /** @addtogroup Common @@ -59,529 +54,13 @@ namespace Dune { typedef T& ParameterType; }; -#ifdef HAVE_TUPLE + // pull in default implementations using std::tuple; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple; -#else - /** - * @brief An empty class. - */ - struct Nil - {}; - - namespace - { - inline const Nil nullType() - { - return Nil(); - } - } - - /** - * @brief A tuple consisting of two objects. - * - * This is similar to std::pair - */ - template<typename T1, typename TT> - struct Pair - { - /** - * @brief The type of the first field. - */ - typedef T1 Type1; - - /** - * @brief The type of the second field. - */ - typedef TT Type2; - // enum{ - // /** - // * @brief The number of values we hold. - // */ - // values = 2; - // }; - - /** - * @brief Constructor - * - * @param t1 The value of the first field. - * @param t2 The value of the second field. - * @param t3 The value of the third field. - * @param t4 The value of the 4th field. - * @param t5 The value of the 5th field. - * @param t6 The value of the 6th field. - * @param t7 The value of the 7th field. - * @param t8 The value of the 8th field. - * @param t9 The value of the 9th field. - */ - template<typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> - Pair(typename TupleAccessTraits<T1>::ParameterType t1, T2& t2, T3& t3, T4& t4, T5& t5, - T6& t6, T7& t7, T8& t8, T9& t9); - - /** - * @brief Constructor - * - * @param t1 The value of the first field. - * @param t2 The value of the second field. - */ - Pair(typename TupleAccessTraits<Type1>::ParameterType t1, TT& t2); - - Pair(); - - /** - * @brief Copy Constructor for implicit type conversion - * @param other The tuple to copy. - */ - template<typename U1, typename U2> - Pair(const Pair<U1,U2>& other); - - /** - * @brief Assignment operator for implicit type conversion - * @param other The tuple to assign. - */ - template<typename U1, typename U2> - Pair& operator=(const Pair<U1,U2>& other); - - Pair& operator=(const Pair& other); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits<Type1>::NonConstType first(); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits<Type1>::ConstType - first() const; - - /** - * @brief Get the second value - * @return The second value - */ - typename TupleAccessTraits<Type2>::NonConstType - second(); - - /** - * @brief Get the second value - * @return The second value - */ - typename TupleAccessTraits<Type2>::ConstType - second() const; - - /** @brief The value of the first field. */ - Type1 first_; - /** @brief The value of the second field. */ - Type2 second_; - - }; - - /** - * @brief A tuple consisting of one object. - * Specialization of Pair that really is a single value. - */ - template<typename T1> - struct Pair<T1,Nil> - { - /** - * @brief The type of the first field. - */ - typedef T1 Type1; - - /** - * @brief The type of the (non-existent) second field is Nil. - * This typedef is useful in template metaprogramming, since it allows - * you to specialise for Nil instead of Pair<T, Nil> - */ - typedef Nil Type2; - - /** - * @brief Constructor. - * @param first The values for the first field. - */ - Pair(typename TupleAccessTraits<T1>::ParameterType first, const Nil&, const Nil&, const Nil&, const Nil&, - const Nil&, const Nil&, const Nil&, const Nil&); - - /** - * @brief Constructor. - * @param first The values for the first field. - */ - Pair(typename TupleAccessTraits<T1>::ParameterType first, - const Nil&); - - Pair(); - - /** - * @brief Copy constructor for type conversion. - */ - template<typename T2> - Pair(const Pair<T2,Nil>& other); - - /** - * @brief Assignment operator for type conversion. - */ - template<typename T2> - Pair& operator=(const Pair<T2,Nil>& other); - - /** - * @brief Assignment operator. - */ - Pair& operator=(const Pair& other); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits<Type1>::NonConstType - first(); - - /** - * @brief Get the first value - * @return The first value - */ - typename TupleAccessTraits<Type1>::ConstType - first() const; - - /** @brief The value of the first field.*/ - Type1 first_; - }; - - - /** - * @brief Converts the Tuple to a list of pairs. - */ - template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> - struct TupleToPairs - { - typedef Pair<T1, typename TupleToPairs<T2,T3,T4,T5,T6,T7,T8,T9,Nil>::Type > Type; - }; - - /** - * @brief Specialization for a tuple consisting only of one type. - */ - template<typename T1> - struct TupleToPairs<T1,Nil,Nil,Nil,Nil,Nil,Nil,Nil,Nil> - { - typedef Pair<T1,Nil> Type; - }; - - /** - * @brief A Tuple of objects. - * - * A maximum of 9 objects is supported. - * - * Use the following construction to access the individual elements. - \code - tuple<std::string, float*, int> my_tuple; - - std:string& s = get<0>(my_tuple); - float* p = get<1>(my_tuple); - - // Access the third element in a generic way - typedef tuple_element<2, tuple<std::string, float*, int> >::type Type; - Type& i = get<2>(my_tuple); - \endcode - */ - template<typename T1 = Nil, typename T2 = Nil, typename T3 = Nil, - typename T4 = Nil, typename T5 = Nil,typename T6 = Nil, - typename T7 = Nil, typename T8 = Nil, typename T9 = Nil> - class tuple : public TupleToPairs<T1,T2,T3,T4,T5,T6,T7,T8,T9>::Type - { - public: - //! Type of the first Pair defining the Tuple - typedef typename TupleToPairs<T1,T2,T3,T4,T5,T6,T7,T8,T9>::Type FirstPair; - - tuple() - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1) - : FirstPair(t1, nullType(), nullType(), nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2) - : FirstPair(t1, t2, nullType(), nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3) - : FirstPair(t1, t2, t3, nullType(), - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4) - : FirstPair(t1, t2, t3, t4, - nullType(), nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4, - typename TupleAccessTraits<T5>::ParameterType t5) - : FirstPair(t1, t2, t3, t4, - t5, nullType(), nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4, - typename TupleAccessTraits<T5>::ParameterType t5, - typename TupleAccessTraits<T6>::ParameterType t6) - : FirstPair(t1, t2, t3, t4, - t5, t6, nullType(), nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4, - typename TupleAccessTraits<T5>::ParameterType t5, - typename TupleAccessTraits<T6>::ParameterType t6, - typename TupleAccessTraits<T7>::ParameterType t7) - : FirstPair(t1, t2, t3, t4, - t5, t6, t7, nullType(), - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4, - typename TupleAccessTraits<T5>::ParameterType t5, - typename TupleAccessTraits<T6>::ParameterType t6, - typename TupleAccessTraits<T7>::ParameterType t7, - typename TupleAccessTraits<T8>::ParameterType t8) - : FirstPair(t1, t2, t3, t4, - t5, t6, t7, t8, - nullType()) - {} - - tuple(typename TupleAccessTraits<T1>::ParameterType t1, - typename TupleAccessTraits<T2>::ParameterType t2, - typename TupleAccessTraits<T3>::ParameterType t3, - typename TupleAccessTraits<T4>::ParameterType t4, - typename TupleAccessTraits<T5>::ParameterType t5, - typename TupleAccessTraits<T6>::ParameterType t6, - typename TupleAccessTraits<T7>::ParameterType t7, - typename TupleAccessTraits<T8>::ParameterType t8, - typename TupleAccessTraits<T9>::ParameterType t9) - : FirstPair(t1, t2, t3, t4, t5, t6, t7, t8, t9) - {} - - template<class U1, class U2> - tuple& operator=(const Pair<U1,U2>& other) - { - FirstPair::operator=(other); - return *this; - } - }; - -#endif - -#ifdef HAVE_TUPLE using std::tuple_element; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple_element; -#else - /** - * @brief Get the type of the N-th element of the tuple. - */ - template<int N, class Tuple> - struct tuple_element - { - /** - * @brief The type of the N-th element of the tuple. - */ - typedef typename tuple_element<N,typename Tuple::FirstPair>::type type; - typedef typename tuple_element<N,typename Tuple::FirstPair>::type Type; - }; - - template<int N, typename T1, typename T2> - struct tuple_element<N,Pair<T1,T2> > - { - /** - * @brief The type of the N-th element of the tuple. - */ - typedef typename tuple_element<N-1,T2>::Type type; - typedef typename tuple_element<N-1,T2>::Type Type; - }; - - /** - * @brief Get the type of the first element of the tuple. - */ - template<typename T1, typename T2> - struct tuple_element<0, Pair<T1,T2> > - { - /** - * @brief The type of the first element of the tuple. - */ - typedef T1 type; - typedef T1 Type; - }; - -#endif - -#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE -#ifdef HAVE_TUPLE using std::get; -#elif defined HAVE_TR1_TUPLE - using std::tr1::get; -#endif - -#else - /** - * @brief Get the N-th element of a tuple. - * - * \warning This is an internal class. Do no use it directly! - */ - template<int N> - struct Element - { - /** - * @brief Get the N-th element of the tuple. - * @param tuple The tuple whose N-th element we want. - * @return The N-th element of the tuple. - */ - template<typename T1, typename T2> - static typename TupleAccessTraits< - typename tuple_element<N,Pair<T1,T2> >::type - >::NonConstType - get(Pair<T1,T2>& tuple) - { - return Element<N-1>::get(tuple.second()); - } - - /** - * @brief Get the N-th element of the tuple. - * @param tuple The tuple whose N-th element we want. - * @return The N-th element of the tuple. - */ - template<typename T1, typename T2> - static typename TupleAccessTraits< - typename tuple_element<N,Pair<T1,T2> >::type - >::ConstType - get(const Pair<T1,T2>& tuple) - { - return Element<N-1>::get(tuple.second()); - } - }; - - /** - * @brief Get the first element of a tuple. - */ - template<> - struct Element<0> - { - /** - * @brief Get the first element of the tuple. - * @param tuple The tuple whose first element we want. - * @return The first element of the tuple. - */ - template<typename T1, typename T2> - static typename TupleAccessTraits<T1>::NonConstType get(Pair<T1,T2>& tuple) - { - return tuple.first(); - } - - /** - * @brief Get the first element of the tuple. - * @param tuple The tuple whose first element we want. - * @return The first element of the tuple. - */ - template<typename T1, typename T2> - static typename TupleAccessTraits<T1>::ConstType get(const Pair<T1,T2>& tuple) - { - return tuple.first(); - } - }; - - template<int i, typename T1, typename T2, typename T3, typename T4, - typename T5, typename T6, typename T7, typename T8, typename T9> - typename TupleAccessTraits<typename tuple_element<i, tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> >::type> - ::NonConstType - get(tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9>& t) - { - return Element<i>::get(t); - } - - template<int i, typename T1, typename T2, typename T3, typename T4, - typename T5, typename T6, typename T7, typename T8, typename T9> - typename TupleAccessTraits<typename tuple_element<i, tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> >::type> - ::ConstType - get(const tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9>& t) - { - return Element<i>::get(t); - } - -#endif - -#ifdef HAVE_TUPLE using std::tuple_size; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tuple_size; -#else - /** - * @brief Template meta_programm to query the size of a tuple - * - */ - template<class T> - struct tuple_size - { - enum { - // @brief The number of Elements in the tuple. - value=tuple_size<typename T::FirstPair>::value - }; - - - }; - - template<typename T1, typename T2> - struct tuple_size<Pair<T1,T2> > - { - enum { value=1+tuple_size<T2>::value}; - }; - - - template<typename T1> - struct tuple_size<Pair<T1,Nil> > - { - enum { value=1}; - }; - - template<> - struct tuple_size<Pair<Nil,Nil> > - { - enum { value=0}; - }; -#endif - - -#ifdef HAVE_TUPLE using std::tie; using std::make_tuple; -#elif defined HAVE_TR1_TUPLE - using std::tr1::tie; - using std::tr1::make_tuple; -#endif template<int i> @@ -641,7 +120,6 @@ namespace Dune { } }; -#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE /** * \brief Print a tuple. */ @@ -793,407 +271,7 @@ namespace Dune { typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> TupleT; return tuple_writer<tuple_size<TupleT>::value>::get(is, t); } -#else - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1, typename T2, typename U1, typename U2> - inline bool operator==(const Pair<T1,T2>& tuple1, const Pair<U1,U2>& tuple2) - { - return (tuple1.first()==tuple2.first() && tuple1.second()==tuple2.second()); - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1, typename T2, typename U1, typename U2> - inline bool operator!=(const Pair<T1,T2>& tuple1, const Pair<U1,U2>& tuple2) - { - return (tuple1.first()!=tuple2.first() || tuple1.second()!=tuple2.second()); - } - - /** - * @brief Less operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1, typename T2, typename U1, typename U2> - inline bool operator<(const Pair<T1,T2>& tuple1, const Pair<U1,U2>& tuple2) - { - return tuple1.first() < tuple2.first() - || (tuple1.first() == tuple2.first() && tuple1.second() < tuple2.second()); - } - - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1,typename U1> - inline bool operator==(const Pair<T1,Nil>& tuple1, const Pair<U1,Nil>& tuple2) - { - return (tuple1.first()==tuple2.first()); - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1, typename U1> - inline bool operator!=(const Pair<T1,Nil>& tuple1, const Pair<U1,Nil>& tuple2) - { - dune_static_assert( (IsInteroperable<T1,U1>::value), - "T1 and U1 have to be interoperable, i.e., either " - "conversion from one to the other must exist." ); - return (tuple1.first()!=tuple2.first()); - } - - /** - * @brief Less operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple, - */ - template<typename T1, typename U1> - inline bool operator<(const Pair<T1,Nil>& tuple1, const Pair<U1,Nil>& tuple2) - { - return (tuple1.first()<tuple2.first()); - } - - /** - * @brief Equality comparison operator for tuples. - * - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return False as the type of the compared objects are different. - */ - template<typename T1,typename U1, typename U2> - inline bool operator==(const Pair<T1,Nil>& tuple1, const Pair<U1,U2>& tuple2) - { - return false; - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return True as the type of the compared objects are different. - */ - template<typename T1, typename U1, typename U2> - inline bool operator!=(const Pair<T1,Nil>& tuple1, const Pair<U1,U2>& tuple2) - { - return true; - } - - - /** - * @brief Equality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return False as the type of the compared objects are different. - */ - template<typename T1, typename T2, typename U1> - inline bool operator==(const Pair<T1,T2>& tuple1, const Pair<U1,Nil>& tuple2) - { - return false; - } - - /** - * @brief Inequality comparison operator for tuples. - * @param tuple1 The first tuple. - * @param tuple2 The second tuple. - * @return True as the type of the compared objects are different. - */ - template<typename T1, typename T2, typename U1> - inline bool operator!=(const Pair<T1,T2>& tuple1, const Pair<U1,Nil>& tuple2) - { - return true; - } - - /** - * @brief Create a tuple and initialize it. - * @param first The value of the first field. - * @param second The value of the second field. - */ - template<typename T1, typename T2> - inline Pair<T1,T2> makePair(const T1& first, const T2& second) - { - return Pair<T1,T2>(first, second); - } - - /** - * @brief Print a pair or tuple. - */ - template<typename T1, typename T2> - inline std::ostream& operator<<(std::ostream& os, const Pair<T1,T2>& pair) - { - os<<pair.first()<<" "<<pair.second(); - return os; - } - - template<typename T1> - inline std::ostream& operator<<(std::ostream& os, const Pair<T1,Nil>& pair) - { - os<<pair.first(); - return os; - } - - /** - * @brief Read a pair or tuple. - */ - template<typename T1, typename T2> - inline std::istream& operator>>(std::istream& is, Pair<T1,T2>& pair) - { - return is >> pair.first() >> pair.second(); - } - - template<typename T1> - inline std::istream& operator>>(std::istream& is, Pair<T1,Nil>& pair) - { - return is >> pair.first(); - } - - template<class T1> - inline tuple<T1&> tie(T1& t1) { - return tuple<T1&> (t1); - } - - template<class T1, class T2> - inline tuple<T1&, T2&> tie(T1& t1, T2& t2) { - return tuple<T1&, T2&> (t1, t2); - } - - template<class T1, class T2, class T3> - inline tuple<T1&, T2&, T3&> tie(T1& t1, T2& t2, T3& t3) { - return tuple<T1&, T2&, T3&> (t1, t2, t3); - } - - template<class T1, class T2, class T3, class T4> - inline tuple<T1&, T2&, T3&, T4&> tie(T1& t1, T2& t2, T3& t3, T4& t4) { - return tuple<T1&, T2&, T3&, T4&> (t1, t2, t3, t4); - } - - template<class T1, class T2, class T3, class T4, class T5> - inline tuple<T1&, T2&, T3&, T4&, T5&> - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) { - return tuple<T1&, T2&, T3&, T4&, T5&> (t1, t2, t3, t4, t5); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6> - inline tuple<T1&, T2&, T3&, T4&, T5&, T6&> - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6) { - return tuple<T1&, T2&, T3&, T4&, T5&, T6&> (t1, t2, t3, t4, t5, t6); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7> - inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&> - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7) { - return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&> (t1, t2, t3, t4, t5, t6, t7); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, - class T8> - inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&> - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) { - return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&> - (t1, t2, t3, t4, t5, t6, t7, t8); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, - class T8, class T9> - inline tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&> - tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9) { - return tuple<T1&, T2&, T3&, T4&, T5&, T6&, T7&, T8&, T9&> - (t1, t2, t3, t4, t5, t6, t7, t8, t9); - } - - template<class T1> - inline tuple<T1> make_tuple(const T1& t1) { - return tuple<T1> (t1); - } - - template<class T1, class T2> - inline tuple<T1, T2> make_tuple(const T1& t1, const T2& t2) { - return tuple<T1, T2> (t1, t2); - } - - template<class T1, class T2, class T3> - inline tuple<T1, T2, T3> make_tuple(const T1& t1, const T2& t2, const T3& t3) { - return tuple<T1, T2, T3> (t1, t2, t3); - } - - template<class T1, class T2, class T3, class T4> - inline tuple<T1, T2, T3, T4> make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4) { - return tuple<T1, T2, T3, T4> (t1, t2, t3, t4); - } - - template<class T1, class T2, class T3, class T4, class T5> - inline tuple<T1, T2, T3, T4, T5> - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { - return tuple<T1, T2, T3, T4, T5> (t1, t2, t3, t4, t5); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6> - inline tuple<T1, T2, T3, T4, T5, T6> - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { - return tuple<T1, T2, T3, T4, T5, T6> (t1, t2, t3, t4, t5, t6); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7> - inline tuple<T1, T2, T3, T4, T5, T6, T7> - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7) { - return tuple<T1, T2, T3, T4, T5, T6, T7> (t1, t2, t3, t4, t5, t6, t7); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, - class T8> - inline tuple<T1, T2, T3, T4, T5, T6, T7, T8> - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7, const T8& t8) { - return tuple<T1, T2, T3, T4, T5, T6, T7, T8> - (t1, t2, t3, t4, t5, t6, t7, t8); - } - - template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, - class T8, class T9> - inline tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> - make_tuple(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, - const T7& t7, const T8& t8, const T9& t9) { - return tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> - (t1, t2, t3, t4, t5, t6, t7, t8, t9); - } - - template<typename T1, typename TT> - template<typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> - inline Pair<T1,TT>::Pair(typename TupleAccessTraits<T1>::ParameterType first, - T2& t2, T3& t3, T4& t4, T5& t5, - T6& t6, T7& t7, T8& t8, T9& t9) - : first_(first), second_(t2,t3,t4,t5,t6,t7,t8,t9, nullType()) - {} - - template <typename T1, typename TT> - inline Pair<T1, TT>::Pair(typename TupleAccessTraits<T1>::ParameterType first, TT& second) - : first_(first), second_(second) - {} - - template<typename T1, typename T2> - inline Pair<T1,T2>::Pair() - : first_(), second_() - {} - - template<typename T1, typename T2> - template<typename U1, typename U2> - inline Pair<T1,T2>::Pair(const Pair<U1,U2>& other) - : first_(other.first_), second_(other.second_) - {} - - template<typename T1, typename T2> - template<typename U1, typename U2> - inline Pair<T1,T2>& Pair<T1,T2>::operator=(const Pair<U1,U2>& other) - { - first_=other.first_; - second_=other.second_; - return *this; - } - - template<typename T1, typename T2> - inline Pair<T1,T2>& Pair<T1,T2>::operator=(const Pair& other) - { - first_=other.first_; - second_=other.second_; - return *this; - } - - template<typename T1, typename T2> - inline typename TupleAccessTraits<T1>::NonConstType - Pair<T1,T2>::first() - { - return first_; - } - - template<typename T1, typename T2> - inline typename TupleAccessTraits<T1>::ConstType - Pair<T1,T2>::first() const - { - return first_; - } - - - template<typename T1, typename T2> - inline typename TupleAccessTraits<T2>::NonConstType - Pair<T1,T2>::second() - { - return second_; - } - - template<typename T1, typename T2> - inline typename TupleAccessTraits<T2>::ConstType - Pair<T1,T2>::second() const - { - return second_; - } - - template<typename T1> - inline Pair<T1,Nil>::Pair(typename TupleAccessTraits<T1>::ParameterType first, - const Nil&, const Nil&, const Nil&, const Nil&, - const Nil&, const Nil&, const Nil&, const Nil&) - : first_(first) - {} - - template <typename T1> - inline Pair<T1, Nil>::Pair(typename TupleAccessTraits<T1>::ParameterType first, - const Nil&) - : first_(first) - {} - - template<typename T1> - inline Pair<T1,Nil>::Pair() - : first_() - {} - - template<typename T1> - template<typename T2> - inline Pair<T1,Nil>::Pair(const Pair<T2,Nil>& other) - : first_(other.first_) - {} - - template<typename T1> - template<typename T2> - Pair<T1,Nil>& Pair<T1,Nil>::operator=(const Pair<T2,Nil>& other) - { - first_ = other.first_; - return *this; - } - - - template<typename T1> - Pair<T1,Nil>& Pair<T1,Nil>::operator=(const Pair& other) - { - first_ = other.first_; - return *this; - } - - template<typename T1> - inline typename TupleAccessTraits<T1>::NonConstType - Pair<T1,Nil>::first() - { - return first_; - } - - template<typename T1> - inline typename TupleAccessTraits<T1>::ConstType - Pair<T1,Nil>::first() const - { - return first_; - } /** }@ */ -#endif } #endif diff --git a/dune/common/tupleutility.hh b/dune/common/tupleutility.hh index e704c7f79f814886a71b3200b60017ce063d6c79..41ca3170ad36dbb2d03a39c5b275a27f82c4a4a5 100644 --- a/dune/common/tupleutility.hh +++ b/dune/common/tupleutility.hh @@ -32,7 +32,7 @@ namespace Dune { */ template <class Tuple> class NullPointerInitialiser { - dune_static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " + static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " "unspecialized version of NullPointerInitialiser. " "NullPointerInitialiser needs to be specialized for " "each possible tuple size. Naturally the number of " @@ -194,7 +194,7 @@ namespace Dune { */ template <template <class> class TypeEvaluator, class TupleType> class ForEachType { - dune_static_assert(AlwaysFalse<TupleType>::value, "Attempt to use the " + static_assert(AlwaysFalse<TupleType>::value, "Attempt to use the " "unspecialized version of ForEachType. ForEachType " "needs to be specialized for each possible tuple " "size. Naturally the number of pre-defined " @@ -1516,7 +1516,7 @@ namespace Dune { integral_constant<std::size_t, start>, FirstPredicateIndex<Tuple, Predicate, start+1> >::type { - dune_static_assert(tuple_size<Tuple>::value == size, "The \"size\" " + static_assert(tuple_size<Tuple>::value == size, "The \"size\" " "template parameter of FirstPredicateIndex is an " "implementation detail and should never be set " "explicitly!"); @@ -1526,7 +1526,7 @@ namespace Dune { template<class Tuple, template<class> class Predicate, std::size_t size> class FirstPredicateIndex<Tuple, Predicate, size, size> { - dune_static_assert(AlwaysFalse<Tuple>::value, "None of the tuple element " + static_assert(AlwaysFalse<Tuple>::value, "None of the tuple element " "types matches the predicate!"); }; #endif // !DOXYGEN @@ -1576,7 +1576,7 @@ namespace Dune { template< class Tuple, class T> struct PushBackTuple { - dune_static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " + static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " "unspecialized version of PushBackTuple. " "PushBackTuple needs to be specialized for " "each possible tuple size. Naturally the number of " @@ -1596,67 +1596,11 @@ namespace Dune { #ifndef DOXYGEN -#if HAVE_VARIADIC_TEMPLATES template<class... TupleArgs, class T> struct PushBackTuple<typename Dune::tuple<TupleArgs...>, T> { typedef typename Dune::tuple<TupleArgs..., T> type; }; -#else - template<class T> - struct PushBackTuple< Dune::tuple<>, T> - { - typedef typename Dune::tuple<T> type; - }; - - template< class T1, class T> - struct PushBackTuple< Dune::tuple<T1>, T> - { - typedef typename Dune::tuple<T1, T> type; - }; - - template< class T1, class T2, class T> - struct PushBackTuple< Dune::tuple<T1, T2>, T> - { - typedef typename Dune::tuple<T1, T2, T> type; - }; - - template< class T1, class T2, class T3, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T> type; - }; - - template< class T1, class T2, class T3, class T4, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3, T4>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T4, T> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T4, T5, T> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T> - struct PushBackTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8>, T> - { - typedef typename Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T> type; - }; -#endif // HAVE_VARIADIC_TEMPLATES #endif @@ -1671,7 +1615,7 @@ namespace Dune { template< class Tuple, class T> struct PushFrontTuple { - dune_static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " + static_assert(AlwaysFalse<Tuple>::value, "Attempt to use the " "unspecialized version of PushFrontTuple. " "PushFrontTuple needs to be specialized for " "each possible tuple size. Naturally the number of " @@ -1691,67 +1635,11 @@ namespace Dune { #ifndef DOXYGEN -#if HAVE_VARIADIC_TEMPLATES template<class... TupleArgs, class T> struct PushFrontTuple<typename Dune::tuple<TupleArgs...>, T> { typedef typename Dune::tuple<T, TupleArgs...> type; }; -#else - template<class T> - struct PushFrontTuple< Dune::tuple<>, T> - { - typedef typename Dune::tuple<T> type; - }; - - template< class T1, class T> - struct PushFrontTuple< Dune::tuple<T1>, T> - { - typedef typename Dune::tuple<T, T1> type; - }; - - template< class T1, class T2, class T> - struct PushFrontTuple< Dune::tuple<T1, T2>, T> - { - typedef typename Dune::tuple<T, T1, T2> type; - }; - - template< class T1, class T2, class T3, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3> type; - }; - - template< class T1, class T2, class T3, class T4, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3, T4> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3, T4, T5> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6, T7> type; - }; - - template< class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T> - struct PushFrontTuple< Dune::tuple<T1, T2, T3, T4, T5, T6, T7, T8>, T> - { - typedef typename Dune::tuple<T, T1, T2, T3, T4, T5, T6, T7, T8> type; - }; -#endif // HAVE_VARIADIC_TEMPLATES #endif diff --git a/dune/common/typetraits.hh b/dune/common/typetraits.hh index 51e4ae66bee6cf82e71a7b3b6829d0f441b03b69..081af88dbd16def75ca44aafd2245f43d5b1f331 100644 --- a/dune/common/typetraits.hh +++ b/dune/common/typetraits.hh @@ -373,44 +373,9 @@ namespace Dune }; #endif -#if DOXYGEN || !HAVE_STD_CONDITIONAL - - /** - * @brief Select a type based on a condition. - * - * If template parameter first is true T1 is selected - * otherwise T2 will be selected. - * The selected type is accessible through the typedef - * type. - * - * \note If available, this uses C++11 std::conditional, otherwise it provides - * a reimplementation. - */ - template<bool first, class T1, class T2> - struct conditional - { - /** - * @brief The selected type - * - * if first is true this will be type T1 and - * T2 otherwise - */ - typedef T1 type; - }; - - template<class T1, class T2> - struct conditional<false,T1,T2> - { - typedef T2 type; - }; - -#else // DOXYGEN || !HAVE_STD_CONDITIONAL - // pull in default implementation using std::conditional; -#endif // DOXYGEN || !HAVE_STD_CONDITIONAL - //////////////////////////////////////////////////////////////////////// // // integral_constant (C++0x 20.7.3 "Helper classes") diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt index c60a1a2ba6e3414f03c611348a6fd6cc9149c817..beaa0b3b389dbadf58ab5d66283cab11fcbcb05b 100644 --- a/m4/CMakeLists.txt +++ b/m4/CMakeLists.txt @@ -8,14 +8,8 @@ install(PROGRAMS ax_lang_compiler_ms.m4 boost_fusion.m4 cxx0x_compiler.m4 - cxx0x_rvaluereference.m4 cxx0x_nullptr.m4 - cxx0x_static_assert.m4 - cxx0x_variadic.m4 - cxx0x_variadic_constructor_sfinae.m4 cxx11_constexpr.m4 - cxx11_initializer_list.m4 - cxx11_conditional.m4 cxx11_final.m4 dune.m4 dune_all.m4 @@ -40,12 +34,10 @@ install(PROGRAMS immdx_lib_metis.m4 inkscape.m4 libtoolcompat.m4 - make_shared.m4 mprotect.m4 mpi-config.m4 opengl.m4 parmetis.m4 - shared_ptr.m4 umfpack.m4 xdr.m4 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dune/aclocal diff --git a/m4/Makefile.am b/m4/Makefile.am index 715117e6672b3c587daec839be0cd2dbb7ba1f8b..3d7e141b40b78299500820677b5ea36911d233ac 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -11,13 +11,7 @@ ALLM4S = \ ax_lang_compiler_ms.m4 \ boost_fusion.m4 \ cxx0x_compiler.m4 \ - cxx0x_rvaluereference.m4 \ cxx0x_nullptr.m4 \ - cxx0x_static_assert.m4 \ - cxx0x_variadic.m4 \ - cxx0x_variadic_constructor_sfinae.m4 \ - cxx11_initializer_list.m4 \ - cxx11_conditional.m4 \ cxx11_constexpr.m4 \ cxx11_final.m4 \ dune.m4 \ @@ -42,12 +36,10 @@ ALLM4S = \ immdx_lib_metis.m4 \ inkscape.m4 \ libtoolcompat.m4 \ - make_shared.m4 \ mpi-config.m4 \ mprotect.m4 \ opengl.m4 \ parmetis.m4 \ - shared_ptr.m4 \ umfpack.m4 \ xdr.m4 diff --git a/m4/cxx0x_rvaluereference.m4 b/m4/cxx0x_rvaluereference.m4 deleted file mode 100644 index 74e649a38b3f960f68ce4f92c0aa71a8d4c81511..0000000000000000000000000000000000000000 --- a/m4/cxx0x_rvaluereference.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# tests compiler support for C++0x rvalue references -# the associated macro is called HAVE_RVALUE_REFERENCES - -AC_DEFUN([RVALUE_REFERENCES_CHECK],[ - AC_CACHE_CHECK([whether rvalue references are supported], dune_cv_rvalue_references_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([#include<cassert> - #include <utility> - int foo(int&& x) { return 1; } - int foo(const int& x) { return -1; } - - template<typename T> - int forward(T&& x) - { - return foo(std::forward<T>(x)); - }], - [ - int i = 0; - assert( forward(i) + forward(int(2)) == 0); - return 0; - ])], - dune_cv_rvalue_references_support=yes, - dune_cv_rvalue_references_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_rvalue_references_support" = xyes; then - AC_DEFINE(HAVE_RVALUE_REFERENCES, 1, [Define to 1 if rvalue references are supported]) - fi -]) diff --git a/m4/cxx0x_static_assert.m4 b/m4/cxx0x_static_assert.m4 deleted file mode 100644 index 3cead1a7d8ef42376ae022039684ad8f15fecc20..0000000000000000000000000000000000000000 --- a/m4/cxx0x_static_assert.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([STATIC_ASSERT_CHECK],[ - AC_CACHE_CHECK([whether static_assert is supported], dune_cv_static_assert_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [[static_assert(true,"MSG")]])], - dune_cv_static_assert_support=yes, - dune_cv_static_assert_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_static_assert_support" = xyes; then - AC_DEFINE(HAVE_STATIC_ASSERT, 1, [Define to 1 if static_assert is supported]) - fi -]) diff --git a/m4/cxx0x_variadic.m4 b/m4/cxx0x_variadic.m4 deleted file mode 100644 index fadecf0f24e1c6ab158c2af5856a5043035cecc3..0000000000000000000000000000000000000000 --- a/m4/cxx0x_variadic.m4 +++ /dev/null @@ -1,36 +0,0 @@ -# tests for C++0x variadic template support -# the associated macro is called HAVE_VARIADIC_TEMPLATES - -AC_DEFUN([VARIADIC_TEMPLATES_CHECK],[ - AC_CACHE_CHECK([whether variadic templates are supported], dune_cv_variadic_templates_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([#include<cassert> - - template<typename... T> - int addints(T... x); - - int add_ints() - { - return 0; - } - - template<typename T1, typename... T> - int add_ints(T1 t1, T... t) - { - return t1 + add_ints(t...); - }], - [ - assert( 5 == add_ints(9,3,-5,-2) ); - return 0; - ])], - dune_cv_variadic_templates_support=yes, - dune_cv_variadic_templates_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_variadic_templates_support" = xyes; then - AC_DEFINE(HAVE_VARIADIC_TEMPLATES, 1, [Define to 1 if variadic templates are supported]) - fi -]) diff --git a/m4/cxx0x_variadic_constructor_sfinae.m4 b/m4/cxx0x_variadic_constructor_sfinae.m4 deleted file mode 100644 index f8adc4fe8b379c7173665cb7e01ccf04ed5fb0e9..0000000000000000000000000000000000000000 --- a/m4/cxx0x_variadic_constructor_sfinae.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# tests whether the compiler supports SFINAE on variadic template constructors -# within template classes. GCC 4.3 fails this test. -# the associated macro is called HAVE_VARIADIC_CONSTRUCTOR_SFINAE - -AC_DEFUN([VARIADIC_CONSTRUCTOR_SFINAE_CHECK],[ - AC_CACHE_CHECK([whether SFINAE on variadic template constructors is fully supported], - dune_cv_variadic_constructor_sfinae_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - #include <functional> - - template<typename... U> - struct A - { - - template<typename... T, - typename = typename std::enable_if<(sizeof...(T) < 2)>::type - > - A(T... t) - : i(1) - {} - - template<typename... T, - typename = typename std::enable_if<(sizeof...(T) >= 2)>::type, - typename = void - > - A(T... t) - : i(-1) - {} - - A() - : i(1) - {} - - int i; - };], - [ - return (A<int>().i + A<int>(2).i + A<int>("foo",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1); - ])], - dune_cv_variadic_constructor_sfinae_support=yes, - dune_cv_variadic_constructor_sfinae_support=no) - AC_LANG_POP - ]) - AS_IF([test "x$dune_cv_variadic_constructor_sfinae_support" = xyes],[ - AC_DEFINE(HAVE_VARIADIC_CONSTRUCTOR_SFINAE, 1, [Define to 1 if SFINAE on variadic template constructors is fully supported]) - ]) -]) diff --git a/m4/cxx11_conditional.m4 b/m4/cxx11_conditional.m4 deleted file mode 100644 index 8bbe0c874e30ffb9eb0d4afa7f245db44d297788..0000000000000000000000000000000000000000 --- a/m4/cxx11_conditional.m4 +++ /dev/null @@ -1,25 +0,0 @@ -# tests for C++11 conditional support -# the associated macro is called HAVE_STD_CONDITIONAL - -AC_DEFUN([CXX11_CONDITIONAL_CHECK],[ - AC_CACHE_CHECK([for C++11 std::conditional], dune_cv_cxx11_conditional_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - - #include <type_traits> - - ], - [ - return std::conditional<true,std::integral_constant<int,0>,void>::type::value; - ])], - dune_cv_cxx11_conditional_support=yes, - dune_cv_cxx11_conditional_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_cxx11_conditional_support" = xyes; then - AC_DEFINE(HAVE_STD_CONDITIONAL, 1, [Define to 1 if C++11 std::conditional is supported]) - fi -]) diff --git a/m4/cxx11_initializer_list.m4 b/m4/cxx11_initializer_list.m4 deleted file mode 100644 index 04fc9ff86bc43fe9e90312a6a5f303585ca1f5aa..0000000000000000000000000000000000000000 --- a/m4/cxx11_initializer_list.m4 +++ /dev/null @@ -1,37 +0,0 @@ -# tests for C++11 initializer list support -# the associated macro is called HAVE_INITIALIZER_LIST - -AC_DEFUN([INITIALIZER_LIST_CHECK],[ - AC_CACHE_CHECK([whether std::initializer_list is supported], dune_cv_initializer_list_support, [ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([GXX0X]) - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - - #include <initializer_list> - #include <vector> - - struct A - { - - A(std::initializer_list<int> il) - : vec(il) - {} - - std::vector<int> vec; - }; - - ], - [ - A a{1,3,4,5}; - return 0; - ])], - dune_cv_initializer_list_support=yes, - dune_cv_initializer_list_support=no) - AC_LANG_POP - ]) - if test "x$dune_cv_initializer_list_support" = xyes; then - AC_DEFINE(HAVE_INITIALIZER_LIST, 1, [Define to 1 if std::initializer_list is supported]) - fi -]) diff --git a/m4/dune_common.m4 b/m4/dune_common.m4 index b2b68ceb7ae7f97789d2722a382b17b81c0a006b..f1fa4d42357f7f7780cfb903f374b01204bb35e1 100644 --- a/m4/dune_common.m4 +++ b/m4/dune_common.m4 @@ -19,16 +19,9 @@ AC_DEFUN([DUNE_COMMON_CHECKS], AC_REQUIRE([DUNE_CHECK_COMPILER]) AC_REQUIRE([GXX0X]) - AC_REQUIRE([STATIC_ASSERT_CHECK]) AC_REQUIRE([NULLPTR_CHECK]) - AC_REQUIRE([SHARED_PTR]) - AC_REQUIRE([VARIADIC_TEMPLATES_CHECK]) - AC_REQUIRE([RVALUE_REFERENCES_CHECK]) - AC_REQUIRE([INITIALIZER_LIST_CHECK]) - AC_REQUIRE([CXX11_CONDITIONAL_CHECK]) AC_REQUIRE([CXX11_CONSTEXPR_CHECK]) AC_REQUIRE([DUNE_BOOST_BASE]) - AC_REQUIRE([MAKE_SHARED]) AC_REQUIRE([DUNE_LINKCXX]) AC_REQUIRE([DUNE_CHECKDEPRECATED]) AC_REQUIRE([DUNE_CHECKFINAL]) diff --git a/m4/dune_tr1_headers.m4 b/m4/dune_tr1_headers.m4 index a1c041b4665280a3e293fac302a20dbd98b57d87..559e94b6b598ed03bfd295606d46401c7fb3caf7 100644 --- a/m4/dune_tr1_headers.m4 +++ b/m4/dune_tr1_headers.m4 @@ -9,17 +9,7 @@ AC_DEFUN([DUNE_TR1_HEADERS], [ [], [enable_tr1_headers=yes]) AS_IF([test "x$enable_tr1_headers" != "xno"], - [AC_CHECK_HEADERS([type_traits tr1/type_traits tuple tr1/tuple]) - AC_CACHE_CHECK([whether <array> C++0x is supported], dune_cv_array_cplusplus0x, [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include <array>]], - [[std::array<int,2> a; a.fill(9);]])], - dune_cv_array_cplusplus0x=yes, - dune_cv_array_cplusplus0x=no) - ]) - AS_IF([test "x$dune_cv_array_cplusplus0x" != "xno"], - [AC_DEFINE([HAVE_ARRAY], 1, [Define to 1 if the header <array> from C++0x is available and supports array::fill]) - ]) + [AC_CHECK_HEADERS([type_traits tr1/type_traits]) AC_CACHE_CHECK([whether integral_constant conforming to C++11 is supported], dune_cv_integral_constant_cplusplus11, [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ diff --git a/m4/make_shared.m4 b/m4/make_shared.m4 deleted file mode 100644 index ad731341d7e168a4ed00c0586a3227feab086fe9..0000000000000000000000000000000000000000 --- a/m4/make_shared.m4 +++ /dev/null @@ -1,35 +0,0 @@ -AC_DEFUN([MAKE_SHARED],[ - AC_REQUIRE([SHARED_PTR]) - AS_IF([test "$SHARED_PTR_NAMESPACE" = "boost"],[ - AC_CHECK_HEADER([boost/make_shared.hpp], - [AC_DEFINE([HAVE_BOOST_MAKE_SHARED_HPP], [1], - [Define to 1 if you have <boost/make_shared.hpp>.]) - ]) - ]) - AC_CACHE_CHECK([whether SHARED_PTR_NAMESPACE ($SHARED_PTR_NAMESPACE) provides make_shared], - dune_cv_make_shared, [ - AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -#if defined(HAVE_MEMORY) -# include <memory> -#endif -#if defined(HAVE_TR1_MEMORY) -# include <tr1/memory> -#endif -#if defined(HAVE_BOOST_SHARED_PTR_HPP) && defined(HAVE_BOOST_MAKE_SHARED_HPP) -# include <boost/shared_ptr.hpp> -# include <boost/make_shared.hpp> -#endif -#include <string> - ]],[[ -$SHARED_PTR_NAMESPACE::make_shared<int>(3); - ]])], - dune_cv_make_shared=yes, - dune_cv_make_shared=no) - AC_LANG_POP - ]) - AS_IF([test "$dune_cv_make_shared" = "yes"],[ - AC_DEFINE([HAVE_MAKE_SHARED], [1], - [Define to 1 if SHARED_PTR_NAMESPACE::make_shared is usable.])]) -]) diff --git a/m4/shared_ptr.m4 b/m4/shared_ptr.m4 deleted file mode 100644 index ab9c75cc990d81ad9fc73fa22e94e1036ac56942..0000000000000000000000000000000000000000 --- a/m4/shared_ptr.m4 +++ /dev/null @@ -1,90 +0,0 @@ -dnl Copyright (C) 2009 Sun Microsystems -dnl This file is free software; Sun Microsystems -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl We check two things: where is the memory include file, and in what -dnl namespace does shared_ptr reside. -dnl We include AC_COMPILE_IFELSE for all the combinations we've seen in the -dnl wild: -dnl -dnl GCC 4.3: namespace: std:: #include <memory> -dnl GCC 4.2: namespace: tr1:: #include <tr1/memory> -dnl GCC 4.2: namespace: boost:: #include <boost/shared_ptr.hpp> -dnl -dnl We define one of HAVE_HAVE_TR1_SHARED_PTR or HAVE_BOOST_SHARED_PTR -dnl depending on location, SHARED_PTR_HEADER to be the header with enclosing -dnl brackety braces in which shared_ptr is defined and SHARED_PTR_NAMESPACE to -dnl be the namespace in -dnl which shared_ptr is defined. -dnl - -AC_DEFUN([SHARED_PTR],[ -dnl AC_REQUIRE([PANDORA_CHECK_CXX_STANDARD]) - AC_REQUIRE([DUNE_TR1_HEADERS]) - AC_LANG_PUSH(C++) - AS_IF([test "x$enable_tr1_headers" != "xno"], - [AC_CHECK_HEADERS([memory tr1/memory])]) - AC_CHECK_HEADERS([boost/shared_ptr.hpp]) - AC_CACHE_CHECK([the location of shared_ptr header file], - [ac_cv_shared_ptr_h],[ - for namespace in std tr1 std::tr1 boost - do - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -#include <string> - -using $namespace::shared_ptr; -using namespace std; - ]],[[ -shared_ptr<string> test_ptr(new string("test string")); - ]])], - [ - ac_cv_shared_ptr_namespace="${namespace}" - ac_cv_shared_ptr_header=missing - break - ],[ - ac_cv_shared_ptr_namespace=missing - ac_cv_shared_ptr_header=missing - ]) - for header in memory tr1/memory boost/shared_ptr.hpp; do - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ -# include <$header> -#include <string> - -using $namespace::shared_ptr; -using namespace std; - ]],[[ -shared_ptr<string> test_ptr(new string("test string")); - ]])], - [ - ac_cv_shared_ptr_namespace="${namespace}" - ac_cv_shared_ptr_header="<${header}>" - break - ],[ - ac_cv_shared_ptr_namespace=missing - ac_cv_shared_ptr_header=missing - ]) - done - if test "$ac_cv_shared_ptr_namespace" != "missing"; then break; fi - done - ]) - AS_IF([ test "x$ac_cv_shared_ptr_namespace" = xmissing ], - [], [ - SHARED_PTR_NAMESPACE=${ac_cv_shared_ptr_namespace} - AC_DEFINE_UNQUOTED([SHARED_PTR_NAMESPACE], - ${ac_cv_shared_ptr_namespace}, - [The namespace in which SHARED_PTR can be found]) - ] - ) - AS_IF([ test "x$ac_cv_shared_ptr_header" = xmissing ], - [], [ - SHARED_PTR_HEADER=${ac_cv_shared_ptr_header} - AC_DEFINE_UNQUOTED([SHARED_PTR_HEADER], - ${ac_cv_shared_ptr_header}, - [The header in which SHARED_PTR can be found]) - ] - ) - AC_LANG_POP() -])