You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB
C++

// -*- c++ -*-
#pragma once
#pragma push_macro("tuple_size")
#define tuple_size tuple_size; \
template <typename _Tuple> struct stupid_microsoft \
_Pragma("pop_macro(\"tuple_size\")")
#include_next <utility>
namespace std
{
template <typename T, T... Vals>
struct integer_sequence {};
template <size_t... Vals>
using index_sequence = integer_sequence<size_t, Vals...>;
// use clang builtin:
// http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151102/142408.html
template <typename T, T N>
using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
template <size_t N>
using make_index_sequence = make_integer_sequence<size_t, N>;
template <typename... Args>
using index_sequence_for = make_index_sequence<sizeof...(Args)>;
// in-place construction
struct in_place_t
{
explicit in_place_t() = default;
};
inline constexpr in_place_t in_place{};
template<class T> struct in_place_type_t
{
explicit in_place_type_t() = default;
};
template<class T> inline constexpr in_place_type_t<T> in_place_type{};
template<size_t I> struct in_place_index_t
{
explicit in_place_index_t() = default;
};
template<size_t I> inline constexpr in_place_index_t<I> in_place_index{};
// as_const
template <typename T>
constexpr std::add_const_t<T>& as_const(T& t) noexcept { return t; }
template <typename T> void as_const(T&& t) noexcept = delete;
// exchange
template <typename T, typename U = T>
constexpr T exchange(T& obj, U&& new_val)
{
T old = std::move(obj);
obj = std::forward<U>(new_val);
return old;
}
}