Skip to content
Snippets Groups Projects
Commit 976d6dc3 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

version 1.1.1 and ported tuples from trunk since not compiling with g++

4.3.x


[[Imported from SVN: r5331]]
parent 927a02de
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ namespace Dune {
//! empty constructor
DoubleLinkedList() DUNE_DEPRECATED;
DoubleLinkedList();
//! copy constructor
DoubleLinkedList (const DoubleLinkedList<T>&);
......
......@@ -6,12 +6,12 @@
#include <ostream>
#include "typetraits.hh"
#include "static_assert.hh"
#include "helpertemplates.hh"
#ifdef HAVE_TUPLE
#include <tuple>
#endif
#ifdef HAVE_TR1_TUPLE
#elif defined HAVE_TR1_TUPLE
#include <tr1/tuple>
#endif
......@@ -438,8 +438,14 @@ namespace Dune {
#endif
#define ElementType tuple_element
#ifdef HAVE_TR1_TUPLE
#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE
#ifdef HAVE_TUPLE
#define TUPLE_NS std
using std::get;
#elif defined HAVE_TR1_TUPLE
#define TUPLE_NS std::tr1
using std::tr1::get;
#endif
// for backwards compatibility
template<int i>
......@@ -447,33 +453,17 @@ namespace Dune {
template<typename T1>
static typename TupleAccessTraits<typename tuple_element<i,T1>::type>::NonConstType get(T1& t)
{
return std::tr1::get<i>(t);
return TUPLE_NS::get<i>(t);
}
template<typename T1>
static typename TupleAccessTraits<typename tuple_element<i,T1>::type>::ConstType get(const T1& t)
{
return std::tr1::get<i>(t);
return TUPLE_NS::get<i>(t);
}
};
#elif defined HAVE_TUPLE
using std::get;
// for backwards compatibility
template<int i>
struct Element {
template<typename T1>
static typename TupleAccessTraits<typename tuple_element<i,T1>::type>::NonConstType get(T1& t)
{
return std::get<i>(t);
}
#undef TUPLE_NS
template<typename T1>
static typename TupleAccessTraits<typename tuple_element<i,T1>::type>::ConstType get(const T1& t)
{
return std::get<i>(t);
}
};
#else
/**
* @brief Get the N-th element of a tuple.
......@@ -548,12 +538,21 @@ namespace Dune {
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_TR1_TUPLE
using std::tr1::tuple_size;
#elif defined HAVE_TUPLE
#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
......@@ -592,13 +591,12 @@ namespace Dune {
#define Size tuple_size
#ifdef HAVE_TR1_TUPLE
using std::tr1::tie;
using std::tr1::make_tuple;
#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
#if defined HAVE_TUPLE || defined HAVE_TR1_TUPLE
......@@ -625,14 +623,78 @@ namespace Dune {
/**
* \brief Print a tuple.
*/
template<typename T1>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1> & t)
{
typedef tuple<T1> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2> & t)
{
typedef tuple<T1,T2> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3> & t)
{
typedef tuple<T1,T2,T3> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4> & t)
{
typedef tuple<T1,T2,T3,T4> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5> & t)
{
typedef tuple<T1,T2,T3,T4,T5> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5,T6> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5,T6,T7> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5,T6,T7,T8> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8, typename T9>
inline std::ostream& operator<<( std::ostream& os, tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> t)
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8, typename T9, typename T10>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> Tuple;
return tuple_writer<tuple_size<Tuple>::value>::put(os, t);
}
#else
/**
......@@ -688,7 +750,8 @@ namespace Dune {
template<typename T1, typename U1>
inline bool operator!=(const Pair<T1,Nil>& tuple1, const Pair<U1,Nil>& tuple2)
{
IsTrue<IsInteroperable<T1,U1>::value>::yes();
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());
}
......
Module: dune-common
Version: 1.1
Version: 1.1.1
Maintainer: dune@dune-project.org
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment