/usr/include/dune/common/std/utility.hh is in libdune-common-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | #ifndef DUNE_COMMON_STD_UTILITY_HH
#define DUNE_COMMON_STD_UTILITY_HH
#include <cstddef>
#include <type_traits>
#include <utility>
#include <dune/common/std/constexpr.hh>
#include <dune/common/std/noexcept.hh>
namespace Dune
{
namespace Std
{
// integer_sequence
// ----------------
/** \brief an implementation of std::integer_sequence to be introduced in
* C++14
*
* \tparam T an integer type
* \tparam ...Ints a non-type parameter pack
*/
template< class T, T... Ints >
class integer_sequence
{
static_assert( std::is_integral< T >::value, "Template parameter T is required to be an integral type" );
public:
#ifndef DOXYGEN
template< class U >
struct rebind
{
typedef integer_sequence< U, static_cast< U >( Ints )... > type;
};
#endif // #ifndef DOXYGEN
/** \brief value type */
typedef T value_type;
/** \brief return number of elements in sequence */
static DUNE_CONSTEXPR std::size_t size () { return sizeof...( Ints ); }
};
// index_sequence
// --------------
/** \brief a function similar to std::index_sequence to be introduced in
* C++14
*
* \tparam ...Ints a non-type parameter pack
*/
template< std::size_t... Ints >
class index_sequence
: public integer_sequence< std::size_t, Ints... >
{};
#ifndef DOXYGEN
// make_index_sequence_impl
// ------------------------
template< std::size_t N >
class make_index_sequence_impl;
template<>
class make_index_sequence_impl< 0u >
{
public:
typedef index_sequence<> type;
};
template<>
class make_index_sequence_impl< 1u >
{
public:
typedef index_sequence< 0 > type;
};
template< std::size_t N >
class make_index_sequence_impl
{
static_assert( N >= 0, "Cannot produce an index sequence of negative length" );
template< std::size_t... I1, std::size_t... I2 >
static index_sequence< I1..., (sizeof...( I1 )+I2)... >
add ( index_sequence< I1... >, index_sequence< I2... > )
{
return index_sequence< I1..., (sizeof...( I1 )+I2)... >();
}
public:
typedef decltype( add( typename make_index_sequence_impl< N/2 >::type(), typename make_index_sequence_impl< N-N/2 >::type() ) ) type;
};
#endif // #ifndef DOXYGEN
// make_index_sequence
// -------------------
/** \fn make_index_sequence
*
* \brief a function similar to std::make_index_sequence to be introduced
* in C++14
*
* \tparam N requested size of index sequence
*/
template< std::size_t N >
static DUNE_CONSTEXPR inline typename make_index_sequence_impl< N >::type make_index_sequence ()
{
return typename make_index_sequence_impl< N >::type();
}
// make_integer_sequence
// ---------------------
/** \fn make_integer_sequence
*
* \brief a function similar to std::make_integer_sequence to be
* introduced in C++14
*
* \tparam T an integer type
* \tparam N requested size of integer sequence
*/
template< class T, T N >
static DUNE_CONSTEXPR inline typename make_index_sequence_impl< N >::type::template rebind< T >::type
make_integer_sequence ()
{
return typename make_index_sequence_impl< N >::type::template rebind< T >::type();
}
// index_sequence_for
// ------------------
/** \fn index_sequence_for
*
* \brief a function similar to std::index_sequence_for to be introduced
* in C++14
*
* \tparam ...T a type parameter pack
*/
template< class... T >
static DUNE_CONSTEXPR inline typename make_index_sequence_impl< sizeof...( T ) >::type
index_sequence_for ()
{
return typename make_index_sequence_impl< sizeof...( T ) >::type();
}
#if HAVE_STD_DECLVAL
using std::declval;
#else
template <class T>
typename std::add_rvalue_reference<T>::type declval() DUNE_NOEXCEPT;
#endif
} // namespace Std
} // namespace Dune
#endif // #ifndef DUNE_COMMON_STD_UTILITY_HH
|