update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -0,0 +1,16 @@
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/leaf/config.hpp>
#include <boost/leaf/capture.hpp>
#include <boost/leaf/common.hpp>
#include <boost/leaf/context.hpp>
#include <boost/leaf/error.hpp>
#include <boost/leaf/exception.hpp>
#include <boost/leaf/handle_errors.hpp>
#include <boost/leaf/on_error.hpp>
#include <boost/leaf/pred.hpp>
#include <boost/leaf/result.hpp>
#include <boost/leaf/to_variant.hpp>

View File

@@ -0,0 +1,190 @@
#ifndef BOOST_LEAF_DETAIL_DEMANGLE_HPP_INCLUDED
#define BOOST_LEAF_DETAIL_DEMANGLE_HPP_INCLUDED
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// This file is based on boost::core::demangle
//
// Copyright 2014 Peter Dimov
// Copyright 2014 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/leaf/config.hpp>
#include <cstring>
namespace boost { namespace leaf {
namespace leaf_detail
{
template <int N>
BOOST_LEAF_CONSTEXPR inline char const * check_prefix( char const * t, char const (&prefix)[N] )
{
return std::strncmp(t,prefix,sizeof(prefix)-1)==0 ? t+sizeof(prefix)-1 : t;
}
}
template <class Name>
inline char const * type()
{
using leaf_detail::check_prefix;
char const * t =
#ifdef __FUNCSIG__
__FUNCSIG__;
#else
__PRETTY_FUNCTION__;
#endif
#if defined(__clang__)
BOOST_LEAF_ASSERT(check_prefix(t,"const char *boost::leaf::type() ")==t+32);
return t+32;
#elif defined(__GNUC__)
BOOST_LEAF_ASSERT(check_prefix(t,"const char* boost::leaf::type() ")==t+32);
return t+32;
#else
char const * clang_style = check_prefix(t,"const char *boost::leaf::type() ");
if( clang_style!=t )
return clang_style;
char const * gcc_style = check_prefix(t,"const char* boost::leaf::type() ");
if( gcc_style!=t )
return gcc_style;
#endif
return t;
}
} }
////////////////////////////////////////
// __has_include is currently supported by GCC and Clang. However GCC 4.9 may have issues and
// returns 1 for 'defined( __has_include )', while '__has_include' is actually not supported:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63662
#if defined(__has_include) && (!defined(__GNUC__) || defined(__clang__) || (__GNUC__ + 0) >= 5)
# if __has_include(<cxxabi.h>)
# define BOOST_LEAF_HAS_CXXABI_H
# endif
#elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ )
# define BOOST_LEAF_HAS_CXXABI_H
#endif
#if defined( BOOST_LEAF_HAS_CXXABI_H )
# include <cxxabi.h>
// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
// (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement
// abi::__cxa_demangle(). We detect this implementation by checking the include guard here.
# if defined( __GABIXX_CXXABI_H__ )
# undef BOOST_LEAF_HAS_CXXABI_H
# else
# include <cstdlib>
# include <cstddef>
# endif
#endif
#if BOOST_LEAF_CFG_STD_STRING
#include <string>
namespace boost { namespace leaf {
namespace leaf_detail
{
inline char const * demangle_alloc( char const * name ) noexcept;
inline void demangle_free( char const * name ) noexcept;
class scoped_demangled_name
{
private:
char const * m_p;
public:
explicit scoped_demangled_name( char const * name ) noexcept :
m_p( demangle_alloc( name ) )
{
}
~scoped_demangled_name() noexcept
{
demangle_free( m_p );
}
char const * get() const noexcept
{
return m_p;
}
scoped_demangled_name( scoped_demangled_name const& ) = delete;
scoped_demangled_name& operator= ( scoped_demangled_name const& ) = delete;
};
#ifdef BOOST_LEAF_HAS_CXXABI_H
inline char const * demangle_alloc( char const * name ) noexcept
{
int status = 0;
std::size_t size = 0;
return abi::__cxa_demangle( name, NULL, &size, &status );
}
inline void demangle_free( char const * name ) noexcept
{
std::free( const_cast< char* >( name ) );
}
inline std::string demangle( char const * name )
{
scoped_demangled_name demangled_name( name );
char const * p = demangled_name.get();
if( !p )
p = name;
return p;
}
#else
inline char const * demangle_alloc( char const * name ) noexcept
{
return name;
}
inline void demangle_free( char const * ) noexcept
{
}
inline char const * demangle( char const * name )
{
return name;
}
#endif
}
} }
#else
namespace boost { namespace leaf {
namespace leaf_detail
{
inline char const * demangle( char const * name )
{
return name;
}
}
} }
#endif
#ifdef BOOST_LEAF_HAS_CXXABI_H
# undef BOOST_LEAF_HAS_CXXABI_H
#endif
#endif

View File

@@ -0,0 +1,100 @@
#ifndef BOOST_LEAF_DETAIL_FUNCTION_TRAITS_HPP_INCLUDED
#define BOOST_LEAF_DETAIL_FUNCTION_TRAITS_HPP_INCLUDED
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/leaf/detail/mp11.hpp>
#include <tuple>
namespace boost { namespace leaf {
namespace leaf_detail
{
template <class T> struct remove_noexcept { using type = T; };
template <class R, class... A> struct remove_noexcept<R(*)(A...) noexcept> { using type = R(*)(A...); };
template <class C, class R, class... A> struct remove_noexcept<R(C::*)(A...) noexcept> { using type = R(C::*)(A...); };
template <class C, class R, class... A> struct remove_noexcept<R(C::*)(A...) const noexcept> { using type = R(C::*)(A...) const; };
template<class...>
struct gcc49_workaround //Thanks Glen Fernandes
{
using type = void;
};
template<class... T>
using void_t = typename gcc49_workaround<T...>::type;
template<class F,class V=void>
struct function_traits_impl
{
constexpr static int arity = -1;
};
template<class F>
struct function_traits_impl<F, void_t<decltype(&F::operator())>>
{
private:
using tr = function_traits_impl<typename remove_noexcept<decltype(&F::operator())>::type>;
public:
using return_type = typename tr::return_type;
static constexpr int arity = tr::arity - 1;
using mp_args = typename leaf_detail_mp11::mp_rest<typename tr::mp_args>;
template <int I>
struct arg:
tr::template arg<I+1>
{
};
};
template<class R, class... A>
struct function_traits_impl<R(A...)>
{
using return_type = R;
static constexpr int arity = sizeof...(A);
using mp_args = leaf_detail_mp11::mp_list<A...>;
template <int I>
struct arg
{
static_assert(I < arity, "I out of range");
using type = typename std::tuple_element<I,std::tuple<A...>>::type;
};
};
template<class F> struct function_traits_impl<F&> : function_traits_impl<F> { };
template<class F> struct function_traits_impl<F&&> : function_traits_impl<F> { };
template<class R, class... A> struct function_traits_impl<R(*)(A...)> : function_traits_impl<R(A...)> { };
template<class R, class... A> struct function_traits_impl<R(* &)(A...)> : function_traits_impl<R(A...)> { };
template<class R, class... A> struct function_traits_impl<R(* const &)(A...)> : function_traits_impl<R(A...)> { };
template<class C, class R, class... A> struct function_traits_impl<R(C::*)(A...)> : function_traits_impl<R(C&,A...)> { };
template<class C, class R, class... A> struct function_traits_impl<R(C::*)(A...) const> : function_traits_impl<R(C const &,A...)> { };
template<class C, class R> struct function_traits_impl<R(C::*)> : function_traits_impl<R(C&)> { };
template <class F>
struct function_traits: function_traits_impl<typename remove_noexcept<F>::type>
{
};
template <class F>
using fn_return_type = typename function_traits<F>::return_type;
template <class F, int I>
using fn_arg_type = typename function_traits<F>::template arg<I>::type;
template <class F>
using fn_mp_args = typename function_traits<F>::mp_args;
}
} }
#endif

View File

@@ -0,0 +1,303 @@
#ifndef BOOST_LEAF_DETAIL_MP11_HPP_INCLUDED
#define BOOST_LEAF_DETAIL_MP11_HPP_INCLUDED
// Copyright 2015-2017 Peter Dimov.
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <type_traits>
#include <cstddef>
namespace boost { namespace leaf { namespace leaf_detail_mp11 {
// mp_list<T...>
template<class... T> struct mp_list
{
};
// mp_identity
template<class T> struct mp_identity
{
using type = T;
};
// mp_inherit
template<class... T> struct mp_inherit: T... {};
// mp_if, mp_if_c
namespace detail
{
template<bool C, class T, class... E> struct mp_if_c_impl
{
};
template<class T, class... E> struct mp_if_c_impl<true, T, E...>
{
using type = T;
};
template<class T, class E> struct mp_if_c_impl<false, T, E>
{
using type = E;
};
} // namespace detail
template<bool C, class T, class... E> using mp_if_c = typename detail::mp_if_c_impl<C, T, E...>::type;
template<class C, class T, class... E> using mp_if = typename detail::mp_if_c_impl<static_cast<bool>(C::value), T, E...>::type;
// mp_bool
template<bool B> using mp_bool = std::integral_constant<bool, B>;
using mp_true = mp_bool<true>;
using mp_false = mp_bool<false>;
// mp_to_bool
template<class T> using mp_to_bool = mp_bool<static_cast<bool>( T::value )>;
// mp_not<T>
template<class T> using mp_not = mp_bool< !T::value >;
// mp_int
template<int I> using mp_int = std::integral_constant<int, I>;
// mp_size_t
template<std::size_t N> using mp_size_t = std::integral_constant<std::size_t, N>;
// mp_set_contains<S, V>
namespace detail
{
template<class S, class V> struct mp_set_contains_impl;
template<template<class...> class L, class... T, class V> struct mp_set_contains_impl<L<T...>, V>
{
using type = mp_to_bool<std::is_base_of<mp_identity<V>, mp_inherit<mp_identity<T>...> > >;
};
} // namespace detail
template<class S, class V> using mp_set_contains = typename detail::mp_set_contains_impl<S, V>::type;
// mp_set_push_back<S, T...>
namespace detail
{
template<class S, class... T> struct mp_set_push_back_impl;
template<template<class...> class L, class... U> struct mp_set_push_back_impl<L<U...>>
{
using type = L<U...>;
};
template<template<class...> class L, class... U, class T1, class... T> struct mp_set_push_back_impl<L<U...>, T1, T...>
{
using S = mp_if<mp_set_contains<L<U...>, T1>, L<U...>, L<U..., T1>>;
using type = typename mp_set_push_back_impl<S, T...>::type;
};
} // namespace detail
template<class S, class... T> using mp_set_push_back = typename detail::mp_set_push_back_impl<S, T...>::type;
// mp_unique<L>
namespace detail
{
template<class L> struct mp_unique_impl;
template<template<class...> class L, class... T> struct mp_unique_impl<L<T...>>
{
using type = mp_set_push_back<L<>, T...>;
};
} // namespace detail
template<class L> using mp_unique = typename detail::mp_unique_impl<L>::type;
// mp_append<L...>
namespace detail
{
template<class... L> struct mp_append_impl;
template<> struct mp_append_impl<>
{
using type = mp_list<>;
};
template<template<class...> class L, class... T> struct mp_append_impl<L<T...>>
{
using type = L<T...>;
};
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2, class... Lr> struct mp_append_impl<L1<T1...>, L2<T2...>, Lr...>
{
using type = typename mp_append_impl<L1<T1..., T2...>, Lr...>::type;
};
}
template<class... L> using mp_append = typename detail::mp_append_impl<L...>::type;
// mp_front<L>
namespace detail
{
template<class L> struct mp_front_impl
{
// An error "no type named 'type'" here means that the argument to mp_front
// is either not a list, or is an empty list
};
template<template<class...> class L, class T1, class... T> struct mp_front_impl<L<T1, T...>>
{
using type = T1;
};
} // namespace detail
template<class L> using mp_front = typename detail::mp_front_impl<L>::type;
// mp_pop_front<L>
namespace detail
{
template<class L> struct mp_pop_front_impl
{
// An error "no type named 'type'" here means that the argument to mp_pop_front
// is either not a list, or is an empty list
};
template<template<class...> class L, class T1, class... T> struct mp_pop_front_impl<L<T1, T...>>
{
using type = L<T...>;
};
} // namespace detail
template<class L> using mp_pop_front = typename detail::mp_pop_front_impl<L>::type;
// mp_first<L>
template<class L> using mp_first = mp_front<L>;
// mp_rest<L>
template<class L> using mp_rest = mp_pop_front<L>;
// mp_remove_if<L, P>
namespace detail
{
template<class L, template<class...> class P> struct mp_remove_if_impl;
template<template<class...> class L, class... T, template<class...> class P> struct mp_remove_if_impl<L<T...>, P>
{
template<class U> using _f = mp_if<P<U>, mp_list<>, mp_list<U>>;
using type = mp_append<L<>, _f<T>...>;
};
} // namespace detail
template<class L, template<class...> class P> using mp_remove_if = typename detail::mp_remove_if_impl<L, P>::type;
// integer_sequence
template<class T, T... I> struct integer_sequence
{
};
// detail::make_integer_sequence_impl
namespace detail
{
// iseq_if_c
template<bool C, class T, class E> struct iseq_if_c_impl;
template<class T, class E> struct iseq_if_c_impl<true, T, E>
{
using type = T;
};
template<class T, class E> struct iseq_if_c_impl<false, T, E>
{
using type = E;
};
template<bool C, class T, class E> using iseq_if_c = typename iseq_if_c_impl<C, T, E>::type;
// iseq_identity
template<class T> struct iseq_identity
{
using type = T;
};
template<class S1, class S2> struct append_integer_sequence;
template<class T, T... I, T... J> struct append_integer_sequence<integer_sequence<T, I...>, integer_sequence<T, J...>>
{
using type = integer_sequence< T, I..., ( J + sizeof...(I) )... >;
};
template<class T, T N> struct make_integer_sequence_impl;
template<class T, T N> struct make_integer_sequence_impl_
{
private:
static_assert( N >= 0, "make_integer_sequence<T, N>: N must not be negative" );
static T const M = N / 2;
static T const R = N % 2;
using S1 = typename make_integer_sequence_impl<T, M>::type;
using S2 = typename append_integer_sequence<S1, S1>::type;
using S3 = typename make_integer_sequence_impl<T, R>::type;
using S4 = typename append_integer_sequence<S2, S3>::type;
public:
using type = S4;
};
template<class T, T N> struct make_integer_sequence_impl: iseq_if_c<N == 0, iseq_identity<integer_sequence<T>>, iseq_if_c<N == 1, iseq_identity<integer_sequence<T, 0>>, make_integer_sequence_impl_<T, N> > >
{
};
} // namespace detail
// make_integer_sequence
template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
// index_sequence
template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
// make_index_sequence
template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
// index_sequence_for
template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
// implementation by Bruno Dutra (by the name is_evaluable)
namespace detail
{
template<template<class...> class F, class... T> struct mp_valid_impl
{
template<template<class...> class G, class = G<T...>> static mp_true check(int);
template<template<class...> class> static mp_false check(...);
using type = decltype(check<F>(0));
};
} // namespace detail
template<template<class...> class F, class... T> using mp_valid = typename detail::mp_valid_impl<F, T...>::type;
} } }
#endif

View File

@@ -0,0 +1,175 @@
#ifndef BOOST_LEAF_DETAIL_OPTIONAL_HPP_INCLUDED
#define BOOST_LEAF_DETAIL_OPTIONAL_HPP_INCLUDED
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/leaf/config.hpp>
#include <utility>
#include <new>
namespace boost { namespace leaf {
namespace leaf_detail
{
template <class T>
class optional
{
int key_;
union { T value_; };
public:
typedef T value_type;
BOOST_LEAF_CONSTEXPR optional() noexcept:
key_(0)
{
}
BOOST_LEAF_CONSTEXPR optional( optional const & x ):
key_(x.key_)
{
if( x.key_ )
(void) new (&value_) T( x.value_ );
}
BOOST_LEAF_CONSTEXPR optional( optional && x ) noexcept:
key_(x.key_)
{
if( x.key_ )
{
(void) new (&value_) T( std::move(x.value_) );
x.reset();
}
}
BOOST_LEAF_CONSTEXPR optional( int key, T const & v ):
key_(key),
value_(v)
{
BOOST_LEAF_ASSERT(!empty());
}
BOOST_LEAF_CONSTEXPR optional( int key, T && v ) noexcept:
key_(key),
value_(std::move(v))
{
BOOST_LEAF_ASSERT(!empty());
}
BOOST_LEAF_CONSTEXPR optional & operator=( optional const & x )
{
reset();
if( int key = x.key() )
{
put(key, x.value_);
key_ = key;
}
return *this;
}
BOOST_LEAF_CONSTEXPR optional & operator=( optional && x ) noexcept
{
reset();
if( int key = x.key() )
{
put(key, std::move(x.value_));
x.reset();
}
return *this;
}
~optional() noexcept
{
reset();
}
BOOST_LEAF_CONSTEXPR bool empty() const noexcept
{
return key_==0;
}
BOOST_LEAF_CONSTEXPR int key() const noexcept
{
return key_;
}
BOOST_LEAF_CONSTEXPR void reset() noexcept
{
if( key_ )
{
value_.~T();
key_=0;
}
}
BOOST_LEAF_CONSTEXPR T & put( int key, T const & v )
{
BOOST_LEAF_ASSERT(key);
reset();
(void) new(&value_) T(v);
key_=key;
return value_;
}
BOOST_LEAF_CONSTEXPR T & put( int key, T && v ) noexcept
{
BOOST_LEAF_ASSERT(key);
reset();
(void) new(&value_) T(std::move(v));
key_=key;
return value_;
}
BOOST_LEAF_CONSTEXPR T const * has_value(int key) const noexcept
{
BOOST_LEAF_ASSERT(key);
return key_==key ? &value_ : nullptr;
}
BOOST_LEAF_CONSTEXPR T * has_value(int key) noexcept
{
BOOST_LEAF_ASSERT(key);
return key_==key ? &value_ : nullptr;
}
BOOST_LEAF_CONSTEXPR T const & value(int key) const & noexcept
{
BOOST_LEAF_ASSERT(has_value(key) != 0);
(void) key;
return value_;
}
BOOST_LEAF_CONSTEXPR T & value(int key) & noexcept
{
BOOST_LEAF_ASSERT(has_value(key) != 0);
(void) key;
return value_;
}
BOOST_LEAF_CONSTEXPR T const && value(int key) const && noexcept
{
BOOST_LEAF_ASSERT(has_value(key) != 0);
(void) key;
return value_;
}
BOOST_LEAF_CONSTEXPR T value(int key) && noexcept
{
BOOST_LEAF_ASSERT(has_value(key) != 0);
(void) key;
T tmp(std::move(value_));
reset();
return tmp;
}
};
}
} }
#endif

View File

@@ -0,0 +1,131 @@
#ifndef BOOST_LEAF_DETAIL_PRINT_HPP_INCLUDED
#define BOOST_LEAF_DETAIL_PRINT_HPP_INCLUDED
// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/leaf/config.hpp>
#include <boost/leaf/detail/demangle.hpp>
#if BOOST_LEAF_CFG_DIAGNOSTICS
#include <type_traits>
#include <exception>
#include <iosfwd>
#include <cstring>
namespace boost { namespace leaf {
namespace leaf_detail
{
template <class T, class E = void>
struct is_printable: std::false_type
{
};
template <class T>
struct is_printable<T, decltype(std::declval<std::ostream&>()<<std::declval<T const &>(), void())>: std::true_type
{
};
////////////////////////////////////////
template <class T, class E = void>
struct has_printable_member_value: std::false_type
{
};
template <class T>
struct has_printable_member_value<T, decltype(std::declval<std::ostream&>()<<std::declval<T const &>().value, void())>: std::true_type
{
};
////////////////////////////////////////
template <
class Wrapper,
bool WrapperPrintable = is_printable<Wrapper>::value,
bool ValuePrintable = has_printable_member_value<Wrapper>::value,
bool IsException = std::is_base_of<std::exception,Wrapper>::value,
bool IsEnum = std::is_enum<Wrapper>::value>
struct diagnostic;
template <class Wrapper, bool ValuePrintable, bool IsException, bool IsEnum>
struct diagnostic<Wrapper, true, ValuePrintable, IsException, IsEnum>
{
static constexpr bool is_invisible = false;
template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, Wrapper const & x )
{
os << x;
}
};
template <class Wrapper, bool IsException, bool IsEnum>
struct diagnostic<Wrapper, false, true, IsException, IsEnum>
{
static constexpr bool is_invisible = false;
template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, Wrapper const & x )
{
os << type<Wrapper>() << ": " << x.value;
}
};
template <class Wrapper, bool IsEnum>
struct diagnostic<Wrapper, false, false, true, IsEnum>
{
static constexpr bool is_invisible = false;
template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, Wrapper const & ex )
{
os << type<Wrapper>() << ": std::exception::what(): " << ex.what();
}
};
template <class Wrapper>
struct diagnostic<Wrapper, false, false, false, false>
{
static constexpr bool is_invisible = false;
template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, Wrapper const & )
{
os << type<Wrapper>() << ": {Non-Printable}";
}
};
template <class Wrapper>
struct diagnostic<Wrapper, false, false, false, true>
{
static constexpr bool is_invisible = false;
template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, Wrapper const & w )
{
os << type<Wrapper>() << ": " << static_cast<typename std::underlying_type<Wrapper>::type>(w);
}
};
template <>
struct diagnostic<std::exception_ptr, false, false, false>
{
static constexpr bool is_invisible = true;
template <class CharT, class Traits>
BOOST_LEAF_CONSTEXPR static void print( std::basic_ostream<CharT, Traits> &, std::exception_ptr const & )
{
}
};
}
} }
#endif
#endif