Skip to content
Snippets Groups Projects
Commit 2f272b99 authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

[typetraits.hh] Add implementation of integral_constant.

If there is an implementation available in std or std::tr1 we fall back to
that.

[[Imported from SVN: r6022]]
parent 8479652f
No related branches found
No related tags found
No related merge requests found
......@@ -369,6 +369,43 @@ namespace Dune
{
typedef T2 Type;
};
////////////////////////////////////////////////////////////////////////
//
// integral_constant (C++0x 20.7.3 "Helper classes")
//
#if defined HAVE_TYPE_TRAITS
using std::integral_constant;
using std::true_type;
using std::false_type;
#elif defined HAVE_TR1_TYPE_TRAITS
using std::tr1::integral_constant;
using std::tr1::true_type;
using std::tr1::false_type;
#else
//! Generate a type for a given integral constant
/**
* \tparam T Type of the constant.
* \tparam v Value of the constant.
*/
template <class T, T v>
struct integral_constant {
//! value this type was generated for
static const T value = v;
//! type of value
typedef T value_type;
//! type of this class itself
typedef integral_constant<T,v> type;
//! conversion to value_type/T
operator value_type() { return value; }
};
//! type for true
typedef integral_constant<bool, true> true_type;
//! type for false
typedef integral_constant<bool, false> false_type;
#endif
/** @} */
}
#endif
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