update modules

This commit is contained in:
2019-01-31 21:16:41 +07:00
parent a3c0573a31
commit 2f16ef0934
17 changed files with 493 additions and 192 deletions

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/invoke.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018 Matvey Cherevko
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/promise.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018 Matvey Cherevko
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/promise.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018 Matvey Cherevko
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/promise.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018 Matvey Cherevko
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -13,6 +13,10 @@
#error "MPark.Variant requires C++11 support."
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
@@ -25,6 +29,14 @@
#define __has_feature(x) 0
#endif
#if __has_attribute(always_inline) || defined(__GNUC__)
#define MPARK_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#elif defined(_MSC_VER)
#define MPARK_ALWAYS_INLINE __forceinline
#else
#define MPARK_ALWAYS_INLINE inline
#endif
#if __has_builtin(__builtin_addressof) || \
(defined(__GNUC__) && __GNUC__ >= 7) || defined(_MSC_VER)
#define MPARK_BUILTIN_ADDRESSOF
@@ -42,8 +54,12 @@
#define MPARK_TYPE_PACK_ELEMENT
#endif
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304 && \
!(defined(_MSC_VER) && _MSC_VER <= 1915)
#if defined(__cpp_constexpr) && __cpp_constexpr >= 200704 && \
!(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 9)
#define MPARK_CPP11_CONSTEXPR
#endif
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304
#define MPARK_CPP14_CONSTEXPR
#endif
@@ -74,6 +90,7 @@
#if !defined(__GLIBCXX__) || __has_include(<codecvt>) // >= libstdc++-5
#define MPARK_TRIVIALITY_TYPE_TRAITS
#define MPARK_INCOMPLETE_TYPE_TRAITS
#endif
#endif // MPARK_CONFIG_HPP

View File

@@ -15,7 +15,8 @@
#include "config.hpp"
#define MPARK_RETURN(...) -> decltype(__VA_ARGS__) { return __VA_ARGS__; }
#define MPARK_RETURN(...) \
noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) { return __VA_ARGS__; }
namespace mpark {
namespace lib {
@@ -205,48 +206,107 @@ namespace mpark {
static constexpr bool value = decltype(test<T>(0))::value;
};
template <typename T, bool = is_swappable<T>::value>
template <bool IsSwappable, typename T>
struct is_nothrow_swappable {
static constexpr bool value =
noexcept(swap(std::declval<T &>(), std::declval<T &>()));
};
template <typename T>
struct is_nothrow_swappable<T, false> : std::false_type {};
struct is_nothrow_swappable<false, T> : std::false_type {};
} // namespace swappable
} // namespace detail
using detail::swappable::is_swappable;
using detail::swappable::is_nothrow_swappable;
template <typename T>
using is_nothrow_swappable =
detail::swappable::is_nothrow_swappable<is_swappable<T>::value, T>;
// <functional>
namespace detail {
template <typename T>
struct is_reference_wrapper : std::false_type {};
template <typename T>
struct is_reference_wrapper<std::reference_wrapper<T>>
: std::true_type {};
template <bool, int>
struct Invoke;
template <>
struct Invoke<true /* pmf */, 0 /* is_base_of */> {
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
MPARK_RETURN((lib::forward<Arg>(arg).*pmf)(lib::forward<Args>(args)...))
};
template <>
struct Invoke<true /* pmf */, 1 /* is_reference_wrapper */> {
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
MPARK_RETURN((lib::forward<Arg>(arg).get().*pmf)(lib::forward<Args>(args)...))
};
template <>
struct Invoke<true /* pmf */, 2 /* otherwise */> {
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
MPARK_RETURN(((*lib::forward<Arg>(arg)).*pmf)(lib::forward<Args>(args)...))
};
template <>
struct Invoke<false /* pmo */, 0 /* is_base_of */> {
template <typename R, typename T, typename Arg>
inline static constexpr auto invoke(R T::*pmo, Arg &&arg)
MPARK_RETURN(lib::forward<Arg>(arg).*pmo)
};
template <>
struct Invoke<false /* pmo */, 1 /* is_reference_wrapper */> {
template <typename R, typename T, typename Arg>
inline static constexpr auto invoke(R T::*pmo, Arg &&arg)
MPARK_RETURN(lib::forward<Arg>(arg).get().*pmo)
};
template <>
struct Invoke<false /* pmo */, 2 /* otherwise */> {
template <typename R, typename T, typename Arg>
inline static constexpr auto invoke(R T::*pmo, Arg &&arg)
MPARK_RETURN((*lib::forward<Arg>(arg)).*pmo)
};
template <typename R, typename T, typename Arg, typename... Args>
inline constexpr auto invoke(R T::*f, Arg &&arg, Args &&... args)
MPARK_RETURN(
Invoke<std::is_function<R>::value,
(std::is_base_of<T, lib::decay_t<Arg>>::value
? 0
: is_reference_wrapper<lib::decay_t<Arg>>::value
? 1
: 2)>::invoke(f,
lib::forward<Arg>(arg),
lib::forward<Args>(args)...))
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
template <typename F, typename... As>
inline constexpr auto invoke(F &&f, As &&... as)
MPARK_RETURN(lib::forward<F>(f)(lib::forward<As>(as)...))
template <typename F, typename... Args>
inline constexpr auto invoke(F &&f, Args &&... args)
MPARK_RETURN(lib::forward<F>(f)(lib::forward<Args>(args)...))
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} // namespace detail
template <typename B, typename T, typename D>
inline constexpr auto invoke(T B::*pmv, D &&d)
MPARK_RETURN(lib::forward<D>(d).*pmv)
template <typename Pmv, typename Ptr>
inline constexpr auto invoke(Pmv pmv, Ptr &&ptr)
MPARK_RETURN((*lib::forward<Ptr>(ptr)).*pmv)
template <typename B, typename T, typename D, typename... As>
inline constexpr auto invoke(T B::*pmf, D &&d, As &&... as)
MPARK_RETURN((lib::forward<D>(d).*pmf)(lib::forward<As>(as)...))
template <typename Pmf, typename Ptr, typename... As>
inline constexpr auto invoke(Pmf pmf, Ptr &&ptr, As &&... as)
MPARK_RETURN(((*lib::forward<Ptr>(ptr)).*pmf)(lib::forward<As>(as)...))
template <typename F, typename... Args>
inline constexpr auto invoke(F &&f, Args &&... args)
MPARK_RETURN(detail::invoke(lib::forward<F>(f),
lib::forward<Args>(args)...))
namespace detail {

View File

@@ -379,9 +379,11 @@ namespace mpark {
#ifdef MPARK_CPP14_CONSTEXPR
template <typename... Traits>
inline constexpr Trait common_trait(Traits... traits) {
inline constexpr Trait common_trait(Traits... traits_) {
Trait result = Trait::TriviallyAvailable;
for (Trait t : {traits...}) {
lib::array<Trait, sizeof...(Traits)> traits = {{traits_...}};
for (std::size_t i = 0; i < sizeof...(Traits); ++i) {
Trait t = traits[i];
if (static_cast<int>(t) > static_cast<int>(result)) {
result = t;
}
@@ -473,8 +475,13 @@ namespace mpark {
struct base {
template <std::size_t I, typename V>
inline static constexpr AUTO_REFREF get_alt(V &&v)
#ifdef _MSC_VER
AUTO_REFREF_RETURN(recursive_union::get_alt(
lib::forward<V>(v).data_, in_place_index_t<I>{}))
#else
AUTO_REFREF_RETURN(recursive_union::get_alt(
data(lib::forward<V>(v)), in_place_index_t<I>{}))
#endif
};
struct variant {
@@ -487,7 +494,207 @@ namespace mpark {
namespace visitation {
#if defined(MPARK_CPP14_CONSTEXPR) && !defined(_MSC_VER)
#define MPARK_VARIANT_SWITCH_VISIT
#endif
struct base {
template <typename Visitor, typename... Vs>
using dispatch_result_t = decltype(
lib::invoke(std::declval<Visitor>(),
access::base::get_alt<0>(std::declval<Vs>())...));
template <typename Expected>
struct expected {
template <typename Actual>
inline static constexpr bool but_got() {
return std::is_same<Expected, Actual>::value;
}
};
template <typename Expected, typename Actual>
struct visit_return_type_check {
static_assert(
expected<Expected>::template but_got<Actual>(),
"`visit` requires the visitor to have a single return type");
template <typename Visitor, typename... Alts>
inline static constexpr DECLTYPE_AUTO invoke(Visitor &&visitor,
Alts &&... alts)
DECLTYPE_AUTO_RETURN(lib::invoke(lib::forward<Visitor>(visitor),
lib::forward<Alts>(alts)...))
};
#ifdef MPARK_VARIANT_SWITCH_VISIT
template <bool B, typename R, typename... ITs>
struct dispatcher;
template <typename R, typename... ITs>
struct dispatcher<false, R, ITs...> {
template <std::size_t B, typename F, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch(
F &&, typename ITs::type &&..., Vs &&...) {
MPARK_BUILTIN_UNREACHABLE;
}
template <std::size_t I, typename F, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch_case(F &&, Vs &&...) {
MPARK_BUILTIN_UNREACHABLE;
}
template <std::size_t B, typename F, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch_at(std::size_t,
F &&,
Vs &&...) {
MPARK_BUILTIN_UNREACHABLE;
}
};
template <typename R, typename... ITs>
struct dispatcher<true, R, ITs...> {
template <std::size_t B, typename F>
MPARK_ALWAYS_INLINE static constexpr R dispatch(
F &&f, typename ITs::type &&... visited_vs) {
using Expected = R;
using Actual = decltype(lib::invoke(
lib::forward<F>(f),
access::base::get_alt<ITs::value>(
lib::forward<typename ITs::type>(visited_vs))...));
return visit_return_type_check<Expected, Actual>::invoke(
lib::forward<F>(f),
access::base::get_alt<ITs::value>(
lib::forward<typename ITs::type>(visited_vs))...);
}
template <std::size_t B, typename F, typename V, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch(
F &&f, typename ITs::type &&... visited_vs, V &&v, Vs &&... vs) {
#define MPARK_DISPATCH(I) \
dispatcher<(I < lib::decay_t<V>::size()), \
R, \
ITs..., \
lib::indexed_type<I, V>>:: \
template dispatch<0>(lib::forward<F>(f), \
lib::forward<typename ITs::type>(visited_vs)..., \
lib::forward<V>(v), \
lib::forward<Vs>(vs)...)
#define MPARK_DEFAULT(I) \
dispatcher<(I < lib::decay_t<V>::size()), R, ITs...>::template dispatch<I>( \
lib::forward<F>(f), \
lib::forward<typename ITs::type>(visited_vs)..., \
lib::forward<V>(v), \
lib::forward<Vs>(vs)...)
switch (v.index()) {
case B + 0: return MPARK_DISPATCH(B + 0);
case B + 1: return MPARK_DISPATCH(B + 1);
case B + 2: return MPARK_DISPATCH(B + 2);
case B + 3: return MPARK_DISPATCH(B + 3);
case B + 4: return MPARK_DISPATCH(B + 4);
case B + 5: return MPARK_DISPATCH(B + 5);
case B + 6: return MPARK_DISPATCH(B + 6);
case B + 7: return MPARK_DISPATCH(B + 7);
case B + 8: return MPARK_DISPATCH(B + 8);
case B + 9: return MPARK_DISPATCH(B + 9);
case B + 10: return MPARK_DISPATCH(B + 10);
case B + 11: return MPARK_DISPATCH(B + 11);
case B + 12: return MPARK_DISPATCH(B + 12);
case B + 13: return MPARK_DISPATCH(B + 13);
case B + 14: return MPARK_DISPATCH(B + 14);
case B + 15: return MPARK_DISPATCH(B + 15);
case B + 16: return MPARK_DISPATCH(B + 16);
case B + 17: return MPARK_DISPATCH(B + 17);
case B + 18: return MPARK_DISPATCH(B + 18);
case B + 19: return MPARK_DISPATCH(B + 19);
case B + 20: return MPARK_DISPATCH(B + 20);
case B + 21: return MPARK_DISPATCH(B + 21);
case B + 22: return MPARK_DISPATCH(B + 22);
case B + 23: return MPARK_DISPATCH(B + 23);
case B + 24: return MPARK_DISPATCH(B + 24);
case B + 25: return MPARK_DISPATCH(B + 25);
case B + 26: return MPARK_DISPATCH(B + 26);
case B + 27: return MPARK_DISPATCH(B + 27);
case B + 28: return MPARK_DISPATCH(B + 28);
case B + 29: return MPARK_DISPATCH(B + 29);
case B + 30: return MPARK_DISPATCH(B + 30);
case B + 31: return MPARK_DISPATCH(B + 31);
default: return MPARK_DEFAULT(B + 32);
}
#undef MPARK_DEFAULT
#undef MPARK_DISPATCH
}
template <std::size_t I, typename F, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch_case(F &&f,
Vs &&... vs) {
using Expected = R;
using Actual = decltype(
lib::invoke(lib::forward<F>(f),
access::base::get_alt<I>(lib::forward<Vs>(vs))...));
return visit_return_type_check<Expected, Actual>::invoke(
lib::forward<F>(f),
access::base::get_alt<I>(lib::forward<Vs>(vs))...);
}
template <std::size_t B, typename F, typename V, typename... Vs>
MPARK_ALWAYS_INLINE static constexpr R dispatch_at(std::size_t index,
F &&f,
V &&v,
Vs &&... vs) {
static_assert(lib::all<(lib::decay_t<V>::size() ==
lib::decay_t<Vs>::size())...>::value,
"all of the variants must be the same size.");
#define MPARK_DISPATCH_AT(I) \
dispatcher<(I < lib::decay_t<V>::size()), R>::template dispatch_case<I>( \
lib::forward<F>(f), lib::forward<V>(v), lib::forward<Vs>(vs)...)
#define MPARK_DEFAULT(I) \
dispatcher<(I < lib::decay_t<V>::size()), R>::template dispatch_at<I>( \
index, lib::forward<F>(f), lib::forward<V>(v), lib::forward<Vs>(vs)...)
switch (index) {
case B + 0: return MPARK_DISPATCH_AT(B + 0);
case B + 1: return MPARK_DISPATCH_AT(B + 1);
case B + 2: return MPARK_DISPATCH_AT(B + 2);
case B + 3: return MPARK_DISPATCH_AT(B + 3);
case B + 4: return MPARK_DISPATCH_AT(B + 4);
case B + 5: return MPARK_DISPATCH_AT(B + 5);
case B + 6: return MPARK_DISPATCH_AT(B + 6);
case B + 7: return MPARK_DISPATCH_AT(B + 7);
case B + 8: return MPARK_DISPATCH_AT(B + 8);
case B + 9: return MPARK_DISPATCH_AT(B + 9);
case B + 10: return MPARK_DISPATCH_AT(B + 10);
case B + 11: return MPARK_DISPATCH_AT(B + 11);
case B + 12: return MPARK_DISPATCH_AT(B + 12);
case B + 13: return MPARK_DISPATCH_AT(B + 13);
case B + 14: return MPARK_DISPATCH_AT(B + 14);
case B + 15: return MPARK_DISPATCH_AT(B + 15);
case B + 16: return MPARK_DISPATCH_AT(B + 16);
case B + 17: return MPARK_DISPATCH_AT(B + 17);
case B + 18: return MPARK_DISPATCH_AT(B + 18);
case B + 19: return MPARK_DISPATCH_AT(B + 19);
case B + 20: return MPARK_DISPATCH_AT(B + 20);
case B + 21: return MPARK_DISPATCH_AT(B + 21);
case B + 22: return MPARK_DISPATCH_AT(B + 22);
case B + 23: return MPARK_DISPATCH_AT(B + 23);
case B + 24: return MPARK_DISPATCH_AT(B + 24);
case B + 25: return MPARK_DISPATCH_AT(B + 25);
case B + 26: return MPARK_DISPATCH_AT(B + 26);
case B + 27: return MPARK_DISPATCH_AT(B + 27);
case B + 28: return MPARK_DISPATCH_AT(B + 28);
case B + 29: return MPARK_DISPATCH_AT(B + 29);
case B + 30: return MPARK_DISPATCH_AT(B + 30);
case B + 31: return MPARK_DISPATCH_AT(B + 31);
default: return MPARK_DEFAULT(B + 32);
}
#undef MPARK_DEFAULT
#undef MPARK_DISPATCH_AT
}
};
#else
template <typename T>
inline static constexpr const T &at(const T &elem) noexcept {
return elem;
@@ -500,93 +707,46 @@ namespace mpark {
}
template <typename F, typename... Fs>
inline static constexpr int visit_visitor_return_type_check() {
static_assert(lib::all<std::is_same<F, Fs>::value...>::value,
"`mpark::visit` requires the visitor to have a single "
"return type.");
return 0;
inline static constexpr lib::array<lib::decay_t<F>, sizeof...(Fs) + 1>
make_farray(F &&f, Fs &&... fs) {
return {{lib::forward<F>(f), lib::forward<Fs>(fs)...}};
}
template <typename... Fs>
inline static constexpr lib::array<
lib::common_type_t<lib::decay_t<Fs>...>,
sizeof...(Fs)>
make_farray(Fs &&... fs) {
using result = lib::array<lib::common_type_t<lib::decay_t<Fs>...>,
sizeof...(Fs)>;
return visit_visitor_return_type_check<lib::decay_t<Fs>...>(),
result{{lib::forward<Fs>(fs)...}};
}
template <std::size_t... Is>
struct dispatcher {
template <typename F, typename... Vs>
struct impl {
inline static constexpr DECLTYPE_AUTO dispatch(F f, Vs... vs)
DECLTYPE_AUTO_RETURN(lib::invoke(
static_cast<F>(f),
access::base::get_alt<Is>(static_cast<Vs>(vs))...))
};
};
template <typename F, typename... Vs, std::size_t... Is>
inline static constexpr AUTO make_dispatch(lib::index_sequence<Is...>)
AUTO_RETURN(&dispatcher<Is...>::template impl<F, Vs...>::dispatch)
template <std::size_t I, typename F, typename... Vs>
inline static constexpr AUTO make_fdiagonal_impl()
AUTO_RETURN(make_dispatch<F, Vs...>(
lib::index_sequence<lib::indexed_type<I, Vs>::value...>{}))
template <typename F, typename... Vs, std::size_t... Is>
inline static constexpr AUTO make_fdiagonal_impl(
lib::index_sequence<Is...>)
AUTO_RETURN(make_farray(make_fdiagonal_impl<Is, F, Vs...>()...))
template <typename F, typename V, typename... Vs>
inline static constexpr /* auto * */ auto make_fdiagonal()
-> decltype(make_fdiagonal_impl<F, V, Vs...>(
lib::make_index_sequence<lib::decay_t<V>::size()>{})) {
static_assert(lib::all<(lib::decay_t<V>::size() ==
lib::decay_t<Vs>::size())...>::value,
"all of the variants must be the same size.");
return make_fdiagonal_impl<F, V, Vs...>(
lib::make_index_sequence<lib::decay_t<V>::size()>{});
}
#ifdef MPARK_RETURN_TYPE_DEDUCTION
template <typename F, typename... Vs, typename Is>
inline static constexpr auto make_fmatrix_impl(Is is) {
return make_dispatch<F, Vs...>(is);
}
template <typename F,
typename... Vs,
typename Is,
std::size_t... Js,
typename... Ls>
inline static constexpr auto make_fmatrix_impl(
Is, lib::index_sequence<Js...>, Ls... ls) {
return make_farray(make_fmatrix_impl<F, Vs...>(
lib::push_back_t<Is, Js>{}, ls...)...);
}
template <typename F, typename... Vs>
inline static constexpr auto make_fmatrix() {
return make_fmatrix_impl<F, Vs...>(
lib::index_sequence<>{},
lib::make_index_sequence<lib::decay_t<Vs>::size()>{}...);
}
#else
template <typename F, typename... Vs>
struct make_fmatrix_impl {
template <std::size_t... Is>
inline static constexpr dispatch_result_t<F, Vs...> dispatch(
F &&f, Vs &&... vs) {
using Expected = dispatch_result_t<F, Vs...>;
using Actual = decltype(lib::invoke(
lib::forward<F>(f),
access::base::get_alt<Is>(lib::forward<Vs>(vs))...));
return visit_return_type_check<Expected, Actual>::invoke(
lib::forward<F>(f),
access::base::get_alt<Is>(lib::forward<Vs>(vs))...);
}
#ifdef MPARK_RETURN_TYPE_DEDUCTION
template <std::size_t... Is>
inline static constexpr auto impl(lib::index_sequence<Is...>) {
return &dispatch<Is...>;
}
template <typename Is, std::size_t... Js, typename... Ls>
inline static constexpr auto impl(Is,
lib::index_sequence<Js...>,
Ls... ls) {
return make_farray(impl(lib::push_back_t<Is, Js>{}, ls...)...);
}
#else
template <typename...>
struct impl;
template <typename Is>
struct impl<Is> {
template <std::size_t... Is>
struct impl<lib::index_sequence<Is...>> {
inline constexpr AUTO operator()() const
AUTO_RETURN(make_dispatch<F, Vs...>(Is{}))
AUTO_RETURN(&dispatch<Is...>)
};
template <typename Is, std::size_t... Js, typename... Ls>
@@ -595,8 +755,17 @@ namespace mpark {
AUTO_RETURN(
make_farray(impl<lib::push_back_t<Is, Js>, Ls...>{}()...))
};
#endif
};
#ifdef MPARK_RETURN_TYPE_DEDUCTION
template <typename F, typename... Vs>
inline static constexpr auto make_fmatrix() {
return make_fmatrix_impl<F, Vs...>::impl(
lib::index_sequence<>{},
lib::make_index_sequence<lib::decay_t<Vs>::size()>{}...);
}
#else
template <typename F, typename... Vs>
inline static constexpr AUTO make_fmatrix()
AUTO_RETURN(
@@ -604,86 +773,141 @@ namespace mpark {
lib::index_sequence<>,
lib::make_index_sequence<lib::decay_t<Vs>::size()>...>{}())
#endif
}; // namespace base
template <typename F, typename... Vs>
using FDiagonal = decltype(base::make_fdiagonal<F, Vs...>());
template <typename F, typename... Vs>
struct make_fdiagonal_impl {
template <std::size_t I>
inline static constexpr dispatch_result_t<F, Vs...> dispatch(
F &&f, Vs &&... vs) {
using Expected = dispatch_result_t<F, Vs...>;
using Actual = decltype(
lib::invoke(lib::forward<F>(f),
access::base::get_alt<I>(lib::forward<Vs>(vs))...));
return visit_return_type_check<Expected, Actual>::invoke(
lib::forward<F>(f),
access::base::get_alt<I>(lib::forward<Vs>(vs))...);
}
template <typename F, typename... Vs>
struct fdiagonal {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4268)
#endif
static constexpr FDiagonal<F, Vs...> value =
base::make_fdiagonal<F, Vs...>();
#ifdef _MSC_VER
#pragma warning(pop)
template <std::size_t... Is>
inline static constexpr AUTO impl(lib::index_sequence<Is...>)
AUTO_RETURN(make_farray(&dispatch<Is>...))
};
template <typename F, typename V, typename... Vs>
inline static constexpr auto make_fdiagonal()
-> decltype(make_fdiagonal_impl<F, V, Vs...>::impl(
lib::make_index_sequence<lib::decay_t<V>::size()>{})) {
static_assert(lib::all<(lib::decay_t<V>::size() ==
lib::decay_t<Vs>::size())...>::value,
"all of the variants must be the same size.");
return make_fdiagonal_impl<F, V, Vs...>::impl(
lib::make_index_sequence<lib::decay_t<V>::size()>{});
}
#endif
};
#if !defined(MPARK_VARIANT_SWITCH_VISIT) && \
(!defined(_MSC_VER) || _MSC_VER >= 1910)
template <typename F, typename... Vs>
constexpr FDiagonal<F, Vs...> fdiagonal<F, Vs...>::value;
template <typename F, typename... Vs>
using FMatrix = decltype(base::make_fmatrix<F, Vs...>());
using fmatrix_t = decltype(base::make_fmatrix<F, Vs...>());
template <typename F, typename... Vs>
struct fmatrix {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4268)
#endif
static constexpr FMatrix<F, Vs...> value =
static constexpr fmatrix_t<F, Vs...> value =
base::make_fmatrix<F, Vs...>();
#ifdef _MSC_VER
#pragma warning(pop)
#endif
};
template <typename F, typename... Vs>
constexpr FMatrix<F, Vs...> fmatrix<F, Vs...>::value;
constexpr fmatrix_t<F, Vs...> fmatrix<F, Vs...>::value;
template <typename F, typename... Vs>
using fdiagonal_t = decltype(base::make_fdiagonal<F, Vs...>());
template <typename F, typename... Vs>
struct fdiagonal {
static constexpr fdiagonal_t<F, Vs...> value =
base::make_fdiagonal<F, Vs...>();
};
template <typename F, typename... Vs>
constexpr fdiagonal_t<F, Vs...> fdiagonal<F, Vs...>::value;
#endif
struct alt {
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index,
Visitor &&visitor,
Vs &&... vs)
DECLTYPE_AUTO_RETURN(base::at(
fdiagonal<Visitor &&,
decltype(as_base(lib::forward<Vs>(vs)))...>::value,
index)(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor,
Vs &&... vs)
#ifdef MPARK_VARIANT_SWITCH_VISIT
DECLTYPE_AUTO_RETURN(
base::dispatcher<
true,
base::dispatch_result_t<Visitor,
decltype(as_base(
lib::forward<Vs>(vs)))...>>::
template dispatch<0>(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#elif !defined(_MSC_VER) || _MSC_VER >= 1910
DECLTYPE_AUTO_RETURN(base::at(
fmatrix<Visitor &&,
decltype(as_base(lib::forward<Vs>(vs)))...>::value,
vs.index()...)(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#else
DECLTYPE_AUTO_RETURN(base::at(
base::make_fmatrix<Visitor &&,
decltype(as_base(lib::forward<Vs>(vs)))...>(),
vs.index()...)(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#endif
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index,
Visitor &&visitor,
Vs &&... vs)
#ifdef MPARK_VARIANT_SWITCH_VISIT
DECLTYPE_AUTO_RETURN(
base::dispatcher<
true,
base::dispatch_result_t<Visitor,
decltype(as_base(
lib::forward<Vs>(vs)))...>>::
template dispatch_at<0>(index,
lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#elif !defined(_MSC_VER) || _MSC_VER >= 1910
DECLTYPE_AUTO_RETURN(base::at(
fdiagonal<Visitor &&,
decltype(as_base(lib::forward<Vs>(vs)))...>::value,
index)(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#else
DECLTYPE_AUTO_RETURN(base::at(
base::make_fdiagonal<Visitor &&,
decltype(as_base(lib::forward<Vs>(vs)))...>(),
index)(lib::forward<Visitor>(visitor),
as_base(lib::forward<Vs>(vs))...))
#endif
};
struct variant {
private:
template <typename Visitor, typename... Values>
struct visit_exhaustive_visitor_check {
static_assert(
lib::is_invocable<Visitor, Values...>::value,
"`mpark::visit` requires the visitor to be exhaustive.");
template <typename Visitor>
struct visitor {
template <typename... Values>
inline static constexpr bool does_not_handle() {
return lib::is_invocable<Visitor, Values...>::value;
}
};
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
inline constexpr DECLTYPE_AUTO operator()(Visitor &&visitor,
Values &&... values) const
template <typename Visitor, typename... Values>
struct visit_exhaustiveness_check {
static_assert(visitor<Visitor>::template does_not_handle<Values...>(),
"`visit` requires the visitor to be exhaustive.");
inline static constexpr DECLTYPE_AUTO invoke(Visitor &&visitor,
Values &&... values)
DECLTYPE_AUTO_RETURN(lib::invoke(lib::forward<Visitor>(visitor),
lib::forward<Values>(values)...))
#ifdef _MSC_VER
#pragma warning(pop)
#endif
};
template <typename Visitor>
@@ -693,11 +917,11 @@ namespace mpark {
template <typename... Alts>
inline constexpr DECLTYPE_AUTO operator()(Alts &&... alts) const
DECLTYPE_AUTO_RETURN(
visit_exhaustive_visitor_check<
visit_exhaustiveness_check<
Visitor,
decltype((lib::forward<Alts>(alts).value))...>{}(
lib::forward<Visitor>(visitor_),
lib::forward<Alts>(alts).value...))
decltype((lib::forward<Alts>(alts).value))...>::
invoke(lib::forward<Visitor>(visitor_),
lib::forward<Alts>(alts).value...))
};
template <typename Visitor>
@@ -705,6 +929,12 @@ namespace mpark {
AUTO_RETURN(value_visitor<Visitor>{lib::forward<Visitor>(visitor)})
public:
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor,
Vs &&... vs)
DECLTYPE_AUTO_RETURN(alt::visit_alt(lib::forward<Visitor>(visitor),
lib::forward<Vs>(vs).impl_...))
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index,
Visitor &&visitor,
@@ -715,10 +945,11 @@ namespace mpark {
lib::forward<Vs>(vs).impl_...))
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor,
Vs &&... vs)
DECLTYPE_AUTO_RETURN(alt::visit_alt(lib::forward<Visitor>(visitor),
lib::forward<Vs>(vs).impl_...))
inline static constexpr DECLTYPE_AUTO visit_value(Visitor &&visitor,
Vs &&... vs)
DECLTYPE_AUTO_RETURN(
visit_alt(make_value_visitor(lib::forward<Visitor>(visitor)),
lib::forward<Vs>(vs)...))
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_value_at(std::size_t index,
@@ -728,13 +959,6 @@ namespace mpark {
visit_alt_at(index,
make_value_visitor(lib::forward<Visitor>(visitor)),
lib::forward<Vs>(vs)...))
template <typename Visitor, typename... Vs>
inline static constexpr DECLTYPE_AUTO visit_value(Visitor &&visitor,
Vs &&... vs)
DECLTYPE_AUTO_RETURN(
visit_alt(make_value_visitor(lib::forward<Visitor>(visitor)),
lib::forward<Vs>(vs)...))
};
} // namespace visitation
@@ -860,13 +1084,13 @@ namespace mpark {
#endif
};
#if defined(_MSC_VER) && _MSC_VER < 1910
#if !defined(_MSC_VER) || _MSC_VER >= 1910
#define MPARK_INHERITING_CTOR(type, base) using base::base;
#else
#define MPARK_INHERITING_CTOR(type, base) \
template <typename... Args> \
inline explicit constexpr type(Args &&... args) \
: base(lib::forward<Args>(args)...) {}
#else
#define MPARK_INHERITING_CTOR(type, base) using base::base;
#endif
template <typename Traits, Trait = Traits::destructible_trait>
@@ -937,9 +1161,9 @@ namespace mpark {
template <std::size_t I, typename T, typename... Args>
inline static T &construct_alt(alt<I, T> &a, Args &&... args) {
::new (static_cast<void *>(lib::addressof(a)))
auto *result = ::new (static_cast<void *>(lib::addressof(a)))
alt<I, T>(in_place_t{}, lib::forward<Args>(args)...);
return a.value;
return result->value;
}
template <typename Rhs>

View File

@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.9
* --------------------------------------------------------
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -49,7 +49,7 @@
#endif
/**
* Copyright (c) 2006-2018 Arseny Kapoulkine
* Copyright (c) 2006-2019 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation

View File

@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.9
* --------------------------------------------------------
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -12766,7 +12766,7 @@ namespace pugi
#endif
/**
* Copyright (c) 2006-2018 Arseny Kapoulkine
* Copyright (c) 2006-2019 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation

View File

@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.9
* --------------------------------------------------------
* Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -1445,7 +1445,7 @@ namespace std
#endif
/**
* Copyright (c) 2006-2018 Arseny Kapoulkine
* Copyright (c) 2006-2019 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation