Skip to content
Snippets Groups Projects
Commit fd11ee3e authored by Ansgar Burchardt's avatar Ansgar Burchardt Committed by Christoph Grüninger
Browse files

Use variadic templates for tuple in- and output operators.

parent c988b45a
No related branches found
No related tags found
No related merge requests found
......@@ -123,153 +123,19 @@ namespace Dune {
/**
* \brief Print a tuple.
*/
template<typename T1>
inline std::ostream& operator<<( std::ostream& os, const tuple<T1> & t)
template<typename... Ts>
inline std::ostream& operator<<(std::ostream& os, const tuple<Ts...>& t)
{
typedef tuple<T1> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::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, const tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> TupleT;
return tuple_writer<tuple_size<TupleT>::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> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::put(os, t);
return tuple_writer<sizeof...(Ts)>::put(os, t);
}
/**
* \brief Read a tuple.
*/
template<typename T1>
inline std::istream& operator>>( std::istream& is, tuple<T1> & t)
{
typedef tuple<T1> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2> & t)
{
typedef tuple<T1,T2> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3> & t)
{
typedef tuple<T1,T2,T3> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4> & t)
{
typedef tuple<T1,T2,T3,T4> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5> & t)
{
typedef tuple<T1,T2,T3,T4,T5> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5,T6> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5,T6,T7> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5,T6,T7,T8> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8, typename T9>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> & t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7,
typename T8, typename T9, typename T10>
inline std::istream& operator>>( std::istream& is, tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> & t)
template<typename... Ts>
inline std::istream& operator>>(std::istream& is, tuple<Ts...>& t)
{
typedef tuple<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> TupleT;
return tuple_writer<tuple_size<TupleT>::value>::get(is, t);
return tuple_writer<sizeof...(Ts)>::get(is, t);
}
/** }@ */
......
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