/*******************************************************************************
*
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
*
* Copyright (C) 2011 by O. Parcollet
*
* TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* TRIQS. If not, see .
*
******************************************************************************/
#pragma once
#include
#include
#include "./macros.hpp"
// backward compat. C++11 compilers.
// new stuff in
namespace std {
namespace c14 {
// helpers
template using conditional_t = typename conditional::type;
template using result_of_t = typename result_of::type;
template using remove_reference_t = typename remove_reference::type;
template using add_const_t = typename add_const::type;
template using remove_const_t = typename remove_const::type;
template using decay_t = typename decay::type;
template using enable_if_t = typename enable_if::type;
// use simply std::c14::plus<>() ...
template struct plus: std::plus{};
template<> struct plus {
template
auto operator()( T&& t, U&& u) const DECL_AND_RETURN(std::forward(t) + std::forward(u));
};
// use simply std::c14::plus<>() ...
template struct greater: std::greater{};
template<> struct greater {
template
auto operator()( T&& t, U&& u) const DECL_AND_RETURN(std::forward(t) > std::forward(u));
};
template struct less: std::less{};
template<> struct less {
template
auto operator()( T&& t, U&& u) const DECL_AND_RETURN(std::forward(t) < std::forward(u));
};
template
std::unique_ptr make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); }
//------------------------------------------------------------------------------------------
//
// sequence from C++14 : from gcc lib 4.9
/// Class template integer_sequence
// Stores a tuple of indices. Used by tuple and pair, and by bind() to
// extract the elements in a tuple.
template
struct _Index_tuple
{
typedef _Index_tuple<_Indexes..., sizeof...(_Indexes)> __next;
};
// Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
template
struct _Build_index_tuple
{
typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type;
};
template<>
struct _Build_index_tuple<0>
{
typedef _Index_tuple<> __type;
};
template
struct integer_sequence
{
typedef _Tp value_type;
static constexpr size_t size() { return sizeof...(_Idx); }
};
template::__type>
struct _Make_integer_sequence;
template
struct _Make_integer_sequence<_Tp, _Num, _Index_tuple<_Idx...>>
{
static_assert( _Num >= 0,
"Cannot make integer sequence of negative length" );
typedef integer_sequence<_Tp, static_cast<_Tp>(_Idx)...> __type;
};
/// Alias template make_integer_sequence
template
using make_integer_sequence
= typename _Make_integer_sequence<_Tp, _Num>::__type;
/// Alias template index_sequence
template
using index_sequence = integer_sequence;
/// Alias template make_index_sequence
template
using make_index_sequence = make_integer_sequence;
/// Alias template index_sequence_for
template
using index_sequence_for = make_index_sequence;
//--------------------------------------------------
}
}
namespace std14 {
using namespace std::c14;
}