diff --git a/OAT.xml b/OAT.xml index 68fe9031d3a6286f0911bd145a985c21f3c5eabe..d60a7f5ab324e604d6d2b12ca5479b947becb492 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1,6 +1,5 @@ - diff --git a/boost/any.hpp b/boost/any.hpp deleted file mode 100755 index 9c2789cba47cbf1839b18d1ca2741b5640d26c0c..0000000000000000000000000000000000000000 --- a/boost/any.hpp +++ /dev/null @@ -1,342 +0,0 @@ -// See http://www.boost.org/libs/any for Documentation. - -#ifndef BOOST_ANY_INCLUDED -#define BOOST_ANY_INCLUDED - -#if defined(_MSC_VER) -# pragma once -#endif - -// what: variant type boost::any -// who: contributed by Kevlin Henney, -// with features contributed and bugs found by -// Antony Polukhin, Ed Brey, Mark Rodgers, -// Peter Dimov, and James Curran -// when: July 2001, April 2013 - 2020 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost -{ - class any - { - public: // structors - - BOOST_CONSTEXPR any() BOOST_NOEXCEPT - : content(0) - { - } - - template - any(const ValueType & value) - : content(new holder< - BOOST_DEDUCED_TYPENAME remove_cv::type>::type - >(value)) - { - } - - any(const any & other) - : content(other.content ? other.content->clone() : 0) - { - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - // Move constructor - any(any&& other) BOOST_NOEXCEPT - : content(other.content) - { - other.content = 0; - } - - // Perfect forwarding of ValueType - template - any(ValueType&& value - , typename boost::disable_if >::type* = 0 // disable if value has type `any&` - , typename boost::disable_if >::type* = 0) // disable if value has type `const ValueType&&` - : content(new holder< typename decay::type >(static_cast(value))) - { - } -#endif - - ~any() BOOST_NOEXCEPT - { - delete content; - } - - public: // modifiers - - any & swap(any & rhs) BOOST_NOEXCEPT - { - placeholder* tmp = content; - content = rhs.content; - rhs.content = tmp; - return *this; - } - - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - any & operator=(const ValueType & rhs) - { - any(rhs).swap(*this); - return *this; - } - - any & operator=(any rhs) - { - rhs.swap(*this); - return *this; - } - -#else - any & operator=(const any& rhs) - { - any(rhs).swap(*this); - return *this; - } - - // move assignment - any & operator=(any&& rhs) BOOST_NOEXCEPT - { - rhs.swap(*this); - any().swap(rhs); - return *this; - } - - // Perfect forwarding of ValueType - template - any & operator=(ValueType&& rhs) - { - any(static_cast(rhs)).swap(*this); - return *this; - } -#endif - - public: // queries - - bool empty() const BOOST_NOEXCEPT - { - return !content; - } - - void clear() BOOST_NOEXCEPT - { - any().swap(*this); - } - - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT - { - return content ? content->type() : boost::typeindex::type_id().type_info(); - } - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - private: // types -#else - public: // types (public so any_cast can be non-friend) -#endif - - class BOOST_SYMBOL_VISIBLE placeholder - { - public: // structors - - virtual ~placeholder() - { - } - - public: // queries - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; - - virtual placeholder * clone() const = 0; - - }; - - template - class holder -#ifndef BOOST_NO_CXX11_FINAL - final -#endif - : public placeholder - { - public: // structors - - holder(const ValueType & value) - : held(value) - { - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - holder(ValueType&& value) - : held(static_cast< ValueType&& >(value)) - { - } -#endif - public: // queries - - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT BOOST_OVERRIDE - { - return boost::typeindex::type_id().type_info(); - } - - placeholder * clone() const BOOST_OVERRIDE - { - return new holder(held); - } - - public: // representation - - ValueType held; - - private: // intentionally left unimplemented - holder & operator=(const holder &); - }; - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - - private: // representation - - template - friend ValueType * any_cast(any *) BOOST_NOEXCEPT; - - template - friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT; - -#else - - public: // representation (public so any_cast can be non-friend) - -#endif - - placeholder * content; - - }; - - inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - - class BOOST_SYMBOL_VISIBLE bad_any_cast : -#ifndef BOOST_NO_RTTI - public std::bad_cast -#else - public std::exception -#endif - { - public: - const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE - { - return "boost::bad_any_cast: " - "failed conversion using boost::any_cast"; - } - }; - - template - ValueType * any_cast(any * operand) BOOST_NOEXCEPT - { - return operand && operand->type() == boost::typeindex::type_id() - ? boost::addressof( - static_cast::type> *>(operand->content)->held - ) - : 0; - } - - template - inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT - { - return any_cast(const_cast(operand)); - } - - template - ValueType any_cast(any & operand) - { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - - - nonref * result = any_cast(boost::addressof(operand)); - if(!result) - boost::throw_exception(bad_any_cast()); - - // Attempt to avoid construction of a temporary object in cases when - // `ValueType` is not a reference. Example: - // `static_cast(*result);` - // which is equal to `std::string(*result);` - typedef BOOST_DEDUCED_TYPENAME boost::conditional< - boost::is_reference::value, - ValueType, - BOOST_DEDUCED_TYPENAME boost::add_reference::type - >::type ref_type; - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4172) // "returning address of local variable or temporary" but *result is not local! -#endif - return static_cast(*result); -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - } - - template - inline ValueType any_cast(const any & operand) - { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - return any_cast(const_cast(operand)); - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline ValueType any_cast(any&& operand) - { - BOOST_STATIC_ASSERT_MSG( - boost::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ - || boost::is_const< typename boost::remove_reference::type >::value, - "boost::any_cast shall not be used for getting nonconst references to temporary objects" - ); - return any_cast(operand); - } -#endif - - - // Note: The "unsafe" versions of any_cast are not part of the - // public interface and may be removed at any time. They are - // required where we know what type is stored in the any and can't - // use typeid() comparison, e.g., when our types may travel across - // different shared libraries. - template - inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT - { - return boost::addressof( - static_cast *>(operand->content)->held - ); - } - - template - inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT - { - return unsafe_any_cast(const_cast(operand)); - } -} - -// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. -// Copyright Antony Polukhin, 2013-2020. -// -// 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) - -#endif diff --git a/boost/dll/import_class.hpp b/boost/dll/import_class.hpp deleted file mode 100755 index bed0b19b3f9a907a66ac7ae3a83ee749638cec66..0000000000000000000000000000000000000000 --- a/boost/dll/import_class.hpp +++ /dev/null @@ -1,565 +0,0 @@ -// Copyright 2015-2018 Klemens D. Morgenstern -// Copyright 2019-2020 Antony Polukhin -// -// 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) - -#ifndef BOOST_DLL_IMPORT_CLASS_HPP_ -#define BOOST_DLL_IMPORT_CLASS_HPP_ - -/// \file boost/dll/import_class.hpp -/// \warning Extremely experimental! Requires C++11! Will change in next version of Boost! boost/dll/import_class.hpp is not included in boost/dll.hpp -/// \brief Contains the boost::dll::experimental::import_class function for importing classes. - -#include -#include -#include - -#if (__cplusplus < 201103L) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201103L) -# error This file requires C++11 at least! -#endif - -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -namespace boost { namespace dll { namespace experimental { - -namespace detail -{ - -template -struct deleter -{ - destructor dtor; - bool use_deleting; - - deleter(const destructor & dtor, bool use_deleting = false) : - dtor(dtor), use_deleting(use_deleting) {} - - void operator()(T*t) - { - if (use_deleting) - dtor.call_deleting(t); - else - { - dtor.call_standard(t); - //the thing is actually an array, so delete[] - auto p = reinterpret_cast(t); - delete [] p; - } - } -}; - -template -struct mem_fn_call_proxy; - -template -struct mem_fn_call_proxy> -{ - typedef boost::dll::experimental::detail::mangled_library_mem_fn mem_fn_t; - Class* t; - mem_fn_t & mem_fn; - - mem_fn_call_proxy(mem_fn_call_proxy&&) = default; - mem_fn_call_proxy(const mem_fn_call_proxy & ) = delete; - mem_fn_call_proxy(Class * t, mem_fn_t & mem_fn) - : t(t), mem_fn(mem_fn) {} - - template - auto operator()(Args&&...args) const - { - return mem_fn(t, std::forward(args)...); - } - -}; - -template -struct mem_fn_call_proxy -{ - T* t; - const std::string &name; - smart_library &_lib; - - mem_fn_call_proxy(mem_fn_call_proxy&&) = default; - mem_fn_call_proxy(const mem_fn_call_proxy&) = delete; - mem_fn_call_proxy(T *t, const std::string &name, smart_library & _lib) - : t(t), name(name), _lib(_lib) {}; - - Return operator()(Args...args) const - { - auto f = _lib.get_mem_fn(name); - return (t->*f)(static_cast(args)...); - } -}; - -} - -template -class imported_class; - -template imported_class -import_class(const smart_library& lib, Args...args); -template imported_class -import_class(const smart_library& lib, const std::string & alias_name, Args...args); -template imported_class -import_class(const smart_library& lib, std::size_t size, Args...args); -template imported_class -import_class(const smart_library& lib, std::size_t size, - const std::string & alias_name, Args...args); - - -/*! This class represents an imported class. - * - * \note It must be constructed via \ref boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * - * \tparam The type or type-alias of the imported class. - */ -template -class imported_class -{ - smart_library _lib; - std::unique_ptr> _data; - bool _is_allocating; - std::size_t _size; - const std::type_info& _ti; - - template - inline std::unique_ptr> make_data(const smart_library& lib, Args ... args); - template - inline std::unique_ptr> make_data(const smart_library& lib, std::size_t size, Args...args); - - template - imported_class(detail::sequence *, const smart_library& lib, Args...args); - - template - imported_class(detail::sequence *, const smart_library& lib, std::size_t size, Args...args); - - template - imported_class(detail::sequence *, smart_library&& lib, Args...args); - - template - imported_class(detail::sequence *, smart_library&& lib, std::size_t size, Args...args); -public: - //alias to construct with explicit parameter list - template - static imported_class make(smart_library&& lib, Args...args) - { - typedef detail::sequence *seq; - return imported_class(seq(), boost::move(lib), static_cast(args)...); - } - - template - static imported_class make(smart_library&& lib, std::size_t size, Args...args) - { - typedef detail::sequence *seq; - return imported_class(seq(), boost::move(lib), size, static_cast(args)...); - } - template - static imported_class make(const smart_library& lib, Args...args) - { - typedef detail::sequence *seq; - return imported_class(seq(), lib, static_cast(args)...); - } - - template - static imported_class make(const smart_library& lib, std::size_t size, Args...args) - { - typedef detail::sequence *seq; - return imported_class(seq(), lib, size, static_cast(args)...); - } - - typedef imported_class base_t; - ///Returns a pointer to the underlying class - T* get() {return _data.get();} - imported_class() = delete; - - imported_class(imported_class&) = delete; - imported_class(imported_class&&) = default; /// ().empty();} - ///Check if the imported class is move-assignable - bool is_move_assignable() {return !_lib.symbol_storage().template get_mem_fn ("operator=").empty();} - ///Check if the imported class is copy-constructible - bool is_copy_constructible() {return !_lib.symbol_storage().template get_constructor().empty();} - ///Check if the imported class is copy-assignable - bool is_copy_assignable() {return !_lib.symbol_storage().template get_mem_fn("operator=").empty();} - - imported_class copy() const; /// move(); /// & lhs) const; - ///Invoke the move assignment. \attention Undefined behaviour if the imported object is not move assignable. - void move_assign( imported_class & lhs); - - ///Check if the class is loaded. - explicit operator bool() const {return _data;} - - ///Get a const reference to the std::type_info. - const std::type_info& get_type_info() {return _ti;}; - - /*! Call a member function. This returns a proxy to the function. - * The proxy mechanic mechanic is necessary, so the signaute can be passed. - * - * \b Example - * - * \code - * im_class.call("function_name")("MyString"); - * \endcode - */ - template - const detail::mem_fn_call_proxy call(const std::string& name) - { - return detail::mem_fn_call_proxy(_data.get(), name, _lib); - } - /*! Call a qualified member function, i.e. const and or volatile. - * - * \b Example - * - * \code - * im_class.call("function_name")("MyString"); - * \endcode - */ - template>> - const detail::mem_fn_call_proxy call(const std::string& name) - { - return detail::mem_fn_call_proxy(_data.get(), name, _lib); - } - ///Overload of ->* for an imported method. - template - const detail::mem_fn_call_proxy> - operator->*(detail::mangled_library_mem_fn& mn) - { - return detail::mem_fn_call_proxy>(_data.get(), mn); - } - - ///Import a method of the class. - template - typename boost::dll::experimental::detail::mangled_import_type>::type - import(const std::string & name) - { - return boost::dll::experimental::import_mangled(_lib, name); - } -}; - - - -//helper function, uses the allocating -template -template -inline std::unique_ptr> imported_class::make_data(const smart_library& lib, Args ... args) -{ - constructor ctor = lib.get_constructor(); - destructor dtor = lib.get_destructor (); - - if (!ctor.has_allocating() || !dtor.has_deleting()) - { - boost::dll::fs::error_code ec; - - ec = boost::dll::fs::make_error_code( - boost::dll::fs::errc::bad_file_descriptor - ); - - // report_error() calls dlsym, do not use it here! - boost::throw_exception( - boost::dll::fs::system_error( - ec, "boost::dll::detail::make_data() failed: no allocating ctor or dtor was found" - ) - ); - } - - return std::unique_ptr> ( - ctor.call_allocating(static_cast(args)...), - detail::deleter(dtor, false /* not deleting dtor*/)); -} - -//helper function, using the standard -template -template -inline std::unique_ptr> imported_class::make_data(const smart_library& lib, std::size_t size, Args...args) -{ - constructor ctor = lib.get_constructor(); - destructor dtor = lib.get_destructor (); - - if (!ctor.has_standard() || !dtor.has_standard()) - { - boost::dll::fs::error_code ec; - - ec = boost::dll::fs::make_error_code( - boost::dll::fs::errc::bad_file_descriptor - ); - - // report_error() calls dlsym, do not use it here! - boost::throw_exception( - boost::dll::fs::system_error( - ec, "boost::dll::detail::make_data() failed: no regular ctor or dtor was found" - ) - ); - } - - T *data = reinterpret_cast(new char[size]); - - ctor.call_standard(data, static_cast(args)...); - - return std::unique_ptr> ( - reinterpret_cast(data), - detail::deleter(dtor, false /* not deleting dtor*/)); - -} - - -template -template -imported_class::imported_class(detail::sequence *, const smart_library & lib, Args...args) - : _lib(lib), - _data(make_data(lib, static_cast(args)...)), - _is_allocating(false), - _size(0), - _ti(lib.get_type_info()) -{ - -} - -template -template -imported_class::imported_class(detail::sequence *, const smart_library & lib, std::size_t size, Args...args) - : _lib(lib), - _data(make_data(lib, size, static_cast(args)...)), - _is_allocating(true), - _size(size), - _ti(lib.get_type_info()) -{ - -} - -template -template -imported_class::imported_class(detail::sequence *, smart_library && lib, Args...args) - : _lib(boost::move(lib)), - _data(make_data(lib, static_cast(args)...)), - _is_allocating(false), - _size(0), - _ti(lib.get_type_info()) -{ - -} - -template -template -imported_class::imported_class(detail::sequence *, smart_library && lib, std::size_t size, Args...args) - : _lib(boost::move(lib)), - _data(make_data(lib, size, static_cast(args)...)), - _is_allocating(true), - _size(size), - _ti(lib.get_type_info()) -{ - -} - -template -inline imported_class boost::dll::experimental::imported_class::copy() const -{ - if (this->_is_allocating) - return imported_class::template make(_lib, *_data); - else - return imported_class::template make(_lib, _size, *_data); -} - -template -inline imported_class boost::dll::experimental::imported_class::move() -{ - if (this->_is_allocating) - return imported_class::template make(_lib, *_data); - else - return imported_class::template make(_lib, _size, *_data); -} - -template -inline void boost::dll::experimental::imported_class::copy_assign(const imported_class& lhs) const -{ - this->call("operator=")(*lhs._data); -} - -template -inline void boost::dll::experimental::imported_class::move_assign(imported_class& lhs) -{ - this->call("operator=")(static_cast(*lhs._data)); -} - - - -/*! -* Returns an instance of \ref imported_class which allows to call or import more functions. -* It takes a copy of the smart_libray, so no added type_aliases will be visible, -* for the object. -* -* Few compilers do implement an allocating constructor, which allows the construction -* of the class without knowing the size. That is not portable, so the actual size of the class -* shall always be provided. -* -* \b Example: -* -* \code -* auto import_class(lib, "class_name", 20, "param1", 42); -* \endcode -* -* In this example we construct an instance of the class "class_name" with the size 20, which has "type_alias" as an alias, -* through a constructor which takes a const-ref of std::string and an std::size_t parameter. -* -* \tparam T Class type or alias -* \tparam Args Constructor argument list. -* \param lib Path to shared library or shared library to load function from. -* \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*. -* \param mode An mode that will be used on library load. -* -* \return class object. -* -* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. -* Overload that accepts path also throws std::bad_alloc in case of insufficient memory. -*/ -template imported_class -import_class(const smart_library& lib_, std::size_t size, Args...args) -{ - smart_library lib(lib_); - - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(const smart_library& lib_, Args...args) -{ - smart_library lib(lib_); - return imported_class::template make(boost::move(lib), static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(const smart_library& lib_, const std::string & alias_name, Args...args) -{ - smart_library lib(lib_); - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(const smart_library& lib_, std::size_t size, const std::string & alias_name, Args...args) -{ - smart_library lib(lib_); - - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(const smart_library& lib_, const std::string & alias_name, std::size_t size, Args...args) -{ - smart_library lib(lib_); - - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(smart_library && lib, Args...args) -{ - return imported_class::template make(boost::move(lib), static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(smart_library && lib, const std::string & alias_name, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(smart_library && lib, std::size_t size, Args...args) -{ - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(smart_library && lib, std::size_t size, const std::string & alias_name, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - -//! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) -template imported_class -import_class(smart_library && lib, const std::string & alias_name, std::size_t size, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(boost::move(lib), size, static_cast(args)...); -} - - - -/*! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * \note This function does add the type alias to the \ref boost::dll::experimental::smart_library. - */ - -template imported_class -import_class(smart_library & lib, Args...args) -{ - return imported_class::template make(lib, static_cast(args)...); -} - -/*! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * \note This function does add the type alias to the \ref boost::dll::experimental::smart_library. - */ -template imported_class -import_class(smart_library & lib, const std::string & alias_name, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(lib, static_cast(args)...); -} - -/*! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * \note This function does add the type alias to the \ref boost::dll::experimental::smart_library. - */ -template imported_class -import_class(smart_library & lib, std::size_t size, Args...args) -{ - return imported_class::template make(lib, size, static_cast(args)...); -} - -/*! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * \note This function does add the type alias to the \ref boost::dll::experimental::smart_library. - */ -template imported_class -import_class(smart_library & lib, std::size_t size, const std::string & alias_name, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(lib, size, static_cast(args)...); -} - -/*! \overload boost::dll::import_class(const smart_library& lib, std::size_t, Args...) - * \note This function does add the type alias to the \ref boost::dll::experimental::smart_library. - */ -template imported_class -import_class(smart_library & lib, const std::string & alias_name, std::size_t size, Args...args) -{ - lib.add_type_alias(alias_name); - return imported_class::template make(lib, size, static_cast(args)...); -} - -} -} -} - - - -#endif /* BOOST_DLL_IMPORT_CLASS_HPP_ */ diff --git a/boost/dll/import_mangled.hpp b/boost/dll/import_mangled.hpp deleted file mode 100755 index 908f10ecd34db007fae56f5cd9858039dcb08504..0000000000000000000000000000000000000000 --- a/boost/dll/import_mangled.hpp +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2015-2018 Klemens D. Morgenstern -// Copyright 2019-2020 Antony Polukhin -// -// 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) - - -#ifndef BOOST_DLL_IMPORT_MANGLED_HPP_ -#define BOOST_DLL_IMPORT_MANGLED_HPP_ - -/// \file boost/dll/import_mangled.hpp -/// \warning Extremely experimental! Requires C++11! Will change in next version of Boost! boost/dll/import_mangled.hpp is not included in boost/dll.hpp -/// \brief Contains the boost::dll::experimental::import_mangled function for importing mangled symbols. - -#include -#if (__cplusplus < 201103L) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201103L) -# error This file requires C++11 at least! -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -namespace boost { namespace dll { namespace experimental { - -namespace detail -{ - -template -class mangled_library_function { - // Copying of `boost::dll::shared_library` is very expensive, so we use a `shared_ptr` to make it faster. - boost::shared_ptr lib_; - function_tuple f_; -public: - constexpr mangled_library_function(const boost::shared_ptr& lib, Ts*... func_ptr) BOOST_NOEXCEPT - : lib_(lib) - , f_(func_ptr...) - {} - - - // Compilation error at this point means that imported function - // was called with unmatching parameters. - // - // Example: - // auto f = dll::import_mangled("function", "lib.so"); - // f("Hello"); // error: invalid conversion from 'const char*' to 'int' - // f(1, 2); // error: too many arguments to function - // f(); // error: too few arguments to function - template - auto operator()(Args&&... args) const - -> decltype( f_(static_cast(args)...) ) - { - return f_(static_cast(args)...); - } -}; - - -template -class mangled_library_mem_fn; - -template -class mangled_library_mem_fn> { - // Copying of `boost::dll::shared_library` is very expensive, so we use a `shared_ptr` to make it faster. - typedef mem_fn_tuple call_tuple_t; - boost::shared_ptr lib_; - call_tuple_t f_; - -public: - constexpr mangled_library_mem_fn(const boost::shared_ptr& lib, typename Ts::mem_fn... func_ptr) BOOST_NOEXCEPT - : lib_(lib) - , f_(func_ptr...) - {} - - template - auto operator()(ClassIn *cl, Args&&... args) const - -> decltype( f_(cl, static_cast(args)...) ) - { - return f_(cl, static_cast(args)...); - } -}; - - - - -// simple enough to be here -template struct is_variable : boost::false_type {}; -template struct is_variable> : boost::is_object {}; - -template ::value, - bool isMemFn = is_mem_fn_seq ::value, - bool isVariable = is_variable ::value> -struct mangled_import_type; - -template -struct mangled_import_type, true,false,false> //is function -{ - typedef boost::dll::experimental::detail::mangled_library_function type; - static type make( - const boost::dll::experimental::smart_library& p, - const std::string& name) - { - return type( - boost::make_shared(p.shared_lib()), - boost::addressof(p.get_function(name))...); - } -}; - -template -struct mangled_import_type, false, true, false> //is member-function -{ - typedef typename boost::dll::experimental::detail::make_mem_fn_seq::type actual_sequence; - typedef typename boost::dll::experimental::detail::mangled_library_mem_fn type; - - - template - static type make_impl( - const boost::dll::experimental::smart_library& p, - const std::string & name, - sequence * ) - { - return type(boost::make_shared(p.shared_lib()), - p.get_mem_fn(name)...); - } - - static type make( - const boost::dll::experimental::smart_library& p, - const std::string& name) - { - return make_impl(p, name, static_cast(nullptr)); - } - -}; - -template -struct mangled_import_type, false, false, true> //is variable -{ - typedef boost::shared_ptr type; - - static type make( - const boost::dll::experimental::smart_library& p, - const std::string& name) - { - return type( - boost::make_shared(p.shared_lib()), - boost::addressof(p.get_variable(name))); - } - -}; - - -} // namespace detail - - -#ifndef BOOST_DLL_DOXYGEN -# define BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE inline typename \ - boost::dll::experimental::detail::mangled_import_type>::type -#endif - -/* - * Variants: - * import_mangled("Stuff"); - * import_mangled("Function"); - * import mangled("Function"); - */ - -/*! -* Returns callable object or boost::shared_ptr that holds the symbol imported -* from the loaded library. Returned value refcounts usage -* of the loaded shared library, so that it won't get unload until all copies of return value -* are not destroyed. -* -* For importing symbols by \b alias names use \forcedlink{import_alias} method. -* -* \b Examples: -* -* \code -* boost::function f = import_mangled("test_lib.so", "integer_func_name"); -* -* auto f_cpp11 = import_mangled("test_lib.so", "integer_func_name"); -* \endcode -* -* \code -* boost::shared_ptr i = import_mangled("test_lib.so", "integer_name"); -* \endcode -* -* Additionally you can also import overloaded symbols, including member-functions. -* -* \code -* auto fp = import_mangled("test_lib.so", "func"); -* \endcode -* -* \code -* auto fp = import_mangled("test_lib.so", "func"); -* \endcode -* -* If qualified member-functions are needed, this can be set by repeating the class name with const or volatile. -* All following signatures after the redifintion will use this, i.e. the latest. -* -* * * \code -* auto fp = import_mangled("test_lib.so", "func"); -* \endcode -* -* \b Template \b parameter \b T: Type of the symbol that we are going to import. Must be explicitly specified. -* -* \param lib Path to shared library or shared library to load function from. -* \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*. -* \param mode An mode that will be used on library load. -* -* \return callable object if T is a function type, or boost::shared_ptr if T is an object type. -* -* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. -* Overload that accepts path also throws std::bad_alloc in case of insufficient memory. -*/ - - -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& lib, const char* name, - load_mode::type mode = load_mode::default_mode) -{ - typedef typename boost::dll::experimental::detail::mangled_import_type< - boost::dll::experimental::detail::sequence> type; - - boost::dll::experimental::smart_library p(lib, mode); - //the load - return type::make(p, name); -} - - - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& lib, const std::string& name, - load_mode::type mode = load_mode::default_mode) -{ - return import_mangled(lib, name.c_str(), mode); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, const char* name) { - typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - return type::make(lib, name); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, const std::string& name) { - return import_mangled(lib, name.c_str()); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const char* name) { - typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - return type::make(lib, name); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const std::string& name) { - return import_mangled(boost::move(lib), name.c_str()); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const char* name) { - typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - boost::shared_ptr p = boost::make_shared(lib); - return type::make(p, name); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const std::string& name) { - return import_mangled(lib, name.c_str()); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const char* name) { - typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - boost::dll::experimental::smart_library p(boost::move(lib)); - - return type::make(p, name); -} - -//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) -template -BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const std::string& name) { - return import_mangled(boost::move(lib), name.c_str()); -} - -#undef BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE - -}}} - - -#endif /* BOOST_DLL_IMPORT_MANGLED_HPP_ */ diff --git a/boost/dll/smart_library.hpp b/boost/dll/smart_library.hpp deleted file mode 100755 index 1df20a24d5448b5a738da387ca1ed309d86b18aa..0000000000000000000000000000000000000000 --- a/boost/dll/smart_library.hpp +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2016 Klemens Morgenstern -// Copyright 2019-2020 Antony Polukhin -// -// 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) - -#ifndef BOOST_DLL_SMART_LIBRARY_HPP_ -#define BOOST_DLL_SMART_LIBRARY_HPP_ - -/// \file boost/dll/smart_library.hpp -/// \warning Extremely experimental! Requires C++11! Will change in next version of Boost! boost/dll/smart_library.hpp is not included in boost/dll.hpp -/// \brief Contains the boost::dll::experimental::smart_library class for loading mangled symbols. - -#include -#if defined(_MSC_VER) // MSVC, Clang-cl, and ICC on Windows -# include -#else -# include -#endif - -#if (__cplusplus < 201103L) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201103L) -# error This file requires C++11 at least! -#endif - -#include -#include -#include -#include -#include -#include -#include - - - -namespace boost { -namespace dll { -namespace experimental { - -using boost::dll::detail::constructor; -using boost::dll::detail::destructor; - -/*! -* \brief This class is an extension of \ref shared_library, which allows to load C++ symbols. -* -* This class allows type safe loading of overloaded functions, member-functions, constructors and variables. -* It also allows to overwrite classes so they can be loaded, while being declared with different names. -* -* \warning Is still very experimental. -* -* Currently known limitations: -* -* Member functions must be defined outside of the class to be exported. That is: -* \code -* //not exported: -* struct BOOST_SYMBOL_EXPORT my_class { void func() {}}; -* //exported -* struct BOOST_SYMBOL_EXPORT my_class { void func();}; -* void my_class::func() {}; -* \endcode -* -* With the current analysis, the first version does get exported in MSVC. -* MinGW also does export it, BOOST_SYMBOL_EXPORT is written before it. To allow this on windows one can use -* BOOST_DLL_MEMBER_EXPORT for this, so that MinGW and MSVC can provide those functions. This does however not work with gcc on linux. -* -* Direct initialization of members. -* On linux the following member variable i will not be initialized when using the allocating constructor: -* \code -* struct BOOST_SYMBOL_EXPORT my_class { int i; my_class() : i(42) {} }; -* \endcode -* -* This does however not happen when the value is set inside the constructor function. -*/ -class smart_library { - shared_library _lib; - detail::mangled_storage_impl _storage; - -public: - /*! - * Get the underlying shared_library - */ - const shared_library &shared_lib() const {return _lib;} - - using mangled_storage = detail::mangled_storage_impl; - /*! - * Access to the mangled storage, which is created on construction. - * - * \throw Nothing. - */ - const mangled_storage &symbol_storage() const {return _storage;} - - ///Overload, for current development. - mangled_storage &symbol_storage() {return _storage;} - - //! \copydoc shared_library::shared_library() - smart_library() BOOST_NOEXCEPT {}; - - //! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) - smart_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) { - _lib.load(lib_path, mode); - _storage.load(lib_path); - } - - //! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) - smart_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) { - load(lib_path, mode, ec); - } - - //! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) - smart_library(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) { - load(lib_path, mode, ec); - } - /*! - * copy a smart_library object. - * - * \param lib A smart_library to move from. - * - * \throw Nothing. - */ - smart_library(const smart_library & lib) BOOST_NOEXCEPT - : _lib(lib._lib), _storage(lib._storage) - {} - /*! - * Move a smart_library object. - * - * \param lib A smart_library to move from. - * - * \throw Nothing. - */ - smart_library(BOOST_RV_REF(smart_library) lib) BOOST_NOEXCEPT - : _lib(boost::move(lib._lib)), _storage(boost::move(lib._storage)) - {} - - /*! - * Construct from a shared_library object. - * - * \param lib A shared_library to move from. - * - * \throw Nothing. - */ - explicit smart_library(const shared_library & lib) BOOST_NOEXCEPT - : _lib(lib) - { - _storage.load(lib.location()); - } - /*! - * Construct from a shared_library object. - * - * \param lib A shared_library to move from. - * - * \throw Nothing. - */ - explicit smart_library(BOOST_RV_REF(shared_library) lib) BOOST_NOEXCEPT - : _lib(boost::move(static_cast(lib))) - { - _storage.load(lib.location()); - } - - /*! - * Destroys the smart_library. - * `unload()` is called if the DLL/DSO was loaded. If library was loaded multiple times - * by different instances of shared_library, the actual DLL/DSO won't be unloaded until - * there is at least one instance of shared_library. - * - * \throw Nothing. - */ - ~smart_library() BOOST_NOEXCEPT {}; - - //! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) - void load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) { - boost::dll::fs::error_code ec; - _storage.load(lib_path); - _lib.load(lib_path, mode, ec); - - if (ec) { - boost::dll::detail::report_error(ec, "load() failed"); - } - } - - //! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) - void load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) { - ec.clear(); - _storage.load(lib_path); - _lib.load(lib_path, mode, ec); - } - - //! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) - void load(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) { - ec.clear(); - _storage.load(lib_path); - _lib.load(lib_path, mode, ec); - } - - /*! - * Load a variable from the referenced library. - * - * Unlinke shared_library::get this function will also load scoped variables, which also includes static class members. - * - * \note When mangled, MSVC will also check the type. - * - * \param name Name of the variable - * \tparam T Type of the variable - * \return A reference to the variable of type T. - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - */ - template - T& get_variable(const std::string &name) const { - return _lib.get(_storage.get_variable(name)); - } - - /*! - * Load a function from the referenced library. - * - * \b Example: - * - * \code - * smart_library lib("test_lib.so"); - * typedef int (&add_ints)(int, int); - * typedef double (&add_doubles)(double, double); - * add_ints f1 = lib.get_function ("func_name"); - * add_doubles f2 = lib.get_function("func_name"); - * \endcode - * - * \note When mangled, MSVC will also check the return type. - * - * \param name Name of the function. - * \tparam Func Type of the function, required for determining the overload - * \return A reference to the function of type F. - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - */ - template - Func& get_function(const std::string &name) const { - return _lib.get(_storage.get_function(name)); - } - - /*! - * Load a member-function from the referenced library. - * - * \b Example (import class is MyClass, which is available inside the library and the host): - * - * \code - * smart_library lib("test_lib.so"); - * - * typedef int MyClass(*func)(int); - * typedef int MyClass(*func_const)(int) const; - * - * add_ints f1 = lib.get_mem_fn ("MyClass::function"); - * add_doubles f2 = lib.get_mem_fn("MyClass::function"); - * \endcode - * - * \note When mangled, MSVC will also check the return type. - * - * \param name Name of the function. - * \tparam Class The class the function is a member of. If Class is const, the function will be assumed as taking a const this-pointer. The same applies for volatile. - * \tparam Func Signature of the function, required for determining the overload - * \return A pointer to the member-function with the signature provided - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - */ - template - typename boost::dll::detail::get_mem_fn_type::mem_fn get_mem_fn(const std::string& name) const { - return _lib.get::mem_fn>( - _storage.get_mem_fn(name) - ); - } - - /*! - * Load a constructor from the referenced library. - * - * \b Example (import class is MyClass, which is available inside the library and the host): - * - * \code - * smart_library lib("test_lib.so"); - * - * constructor(); - * \endcode - * - * \tparam Signature Signature of the function, required for determining the overload. The return type is the class which this is the constructor of. - * \return A constructor object. - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - */ - template - constructor get_constructor() const { - return boost::dll::detail::load_ctor(_lib, _storage.get_constructor()); - } - - /*! - * Load a destructor from the referenced library. - * - * \b Example (import class is MyClass, which is available inside the library and the host): - * - * \code - * smart_library lib("test_lib.so"); - * - * destructor f1 = lib.get_mem_fn(); - * \endcode - * - * \tparam Class The class whose destructor shall be loaded - * \return A destructor object. - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - * - */ - template - destructor get_destructor() const { - return boost::dll::detail::load_dtor(_lib, _storage.get_destructor()); - } - /*! - * Load the typeinfo of the given type. - * - * \b Example (import class is MyClass, which is available inside the library and the host): - * - * \code - * smart_library lib("test_lib.so"); - * - * std::type_info &ti = lib.get_Type_info(); - * \endcode - * - * \tparam Class The class whose typeinfo shall be loaded - * \return A reference to a type_info object. - * - * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. - * - */ - template - const std::type_info& get_type_info() const - { - return boost::dll::detail::load_type_info(_lib, _storage); - } - /** - * This function can be used to add a type alias. - * - * This is to be used, when a class shall be imported, which is not declared on the host side. - * - * Example: - * \code - * smart_library lib("test_lib.so"); - * - * lib.add_type_alias("MyClass"); //when using MyAlias, the library will look for MyClass - * - * //get the destructor of MyClass - * destructor dtor = lib.get_destructor(); - * \endcode - * - * - * \param name Name of the class the alias is for. - * - * \attention If the alias-type is not large enough for the imported class, it will result in undefined behaviour. - * \warning The alias will only be applied for the type signature, it will not replace the token in the scoped name. - */ - template void add_type_alias(const std::string& name) { - this->_storage.add_alias(name); - } - - //! \copydoc shared_library::unload() - void unload() BOOST_NOEXCEPT { - _storage.clear(); - _lib.unload(); - } - - //! \copydoc shared_library::is_loaded() const - bool is_loaded() const BOOST_NOEXCEPT { - return _lib.is_loaded(); - } - - //! \copydoc shared_library::operator!() const - bool operator!() const BOOST_NOEXCEPT { - return !is_loaded(); - } - - //! \copydoc shared_library::operator bool() const - BOOST_EXPLICIT_OPERATOR_BOOL() - - //! \copydoc shared_library::has(const char* symbol_name) const - bool has(const char* symbol_name) const BOOST_NOEXCEPT { - return _lib.has(symbol_name); - } - - //! \copydoc shared_library::has(const std::string& symbol_name) const - bool has(const std::string& symbol_name) const BOOST_NOEXCEPT { - return _lib.has(symbol_name); - } - - //! \copydoc shared_library::assign(const shared_library& lib) - smart_library& assign(const smart_library& lib) { - _lib.assign(lib._lib); - _storage.assign(lib._storage); - return *this; - } - - //! \copydoc shared_library::swap(shared_library& rhs) - void swap(smart_library& rhs) BOOST_NOEXCEPT { - _lib.swap(rhs._lib); - _storage.swap(rhs._storage); - } -}; - -/// Very fast equality check that compares the actual DLL/DSO objects. Throws nothing. -inline bool operator==(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { - return lhs.shared_lib().native() == rhs.shared_lib().native(); -} - -/// Very fast inequality check that compares the actual DLL/DSO objects. Throws nothing. -inline bool operator!=(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { - return lhs.shared_lib().native() != rhs.shared_lib().native(); -} - -/// Compare the actual DLL/DSO objects without any guarantee to be stable between runs. Throws nothing. -inline bool operator<(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { - return lhs.shared_lib().native() < rhs.shared_lib().native(); -} - -/// Swaps two shared libraries. Does not invalidate symbols and functions loaded from libraries. Throws nothing. -inline void swap(smart_library& lhs, smart_library& rhs) BOOST_NOEXCEPT { - lhs.swap(rhs); -} - - -#ifdef BOOST_DLL_DOXYGEN -/** Helper functions for overloads. - * - * Gets either a variable, function or member-function, depending on the signature. - * - * @code - * smart_library sm("lib.so"); - * get(sm, "space::value"); //import a variable - * get(sm, "space::func"); //import a function - * get(sm, "space::class_::mem_fn"); //import a member function - * @endcode - * - * @param sm A reference to the @ref smart_library - * @param name The name of the entity to import - */ -template -void get(const smart_library& sm, const std::string &name); -#endif - -template -typename boost::enable_if, T&>::type get(const smart_library& sm, const std::string &name) - -{ - return sm.get_variable(name); -} - -template -typename boost::enable_if, T&>::type get(const smart_library& sm, const std::string &name) -{ - return sm.get_function(name); -} - -template -auto get(const smart_library& sm, const std::string &name) -> typename detail::get_mem_fn_type::mem_fn -{ - return sm.get_mem_fn(name); -} - - -} /* namespace experimental */ -} /* namespace dll */ -} /* namespace boost */ - -#endif /* BOOST_DLL_SMART_LIBRARY_HPP_ */ diff --git a/boost/dynamic_bitset/detail/dynamic_bitset.hpp b/boost/dynamic_bitset/detail/dynamic_bitset.hpp deleted file mode 100755 index 538f2457acfb228ce0dc493c928ac67255bf05da..0000000000000000000000000000000000000000 --- a/boost/dynamic_bitset/detail/dynamic_bitset.hpp +++ /dev/null @@ -1,307 +0,0 @@ -// ----------------------------------------------------------- -// -// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek -// Copyright (c) 2003-2006, 2008 Gennaro Prota -// Copyright (c) 2014 Glen Joseph Fernandes -// (glenjofe@gmail.com) -// Copyright (c) 2018 Evgeny Shulgin -// Copyright (c) 2019 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) -// -// ----------------------------------------------------------- - -#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP -#define BOOST_DETAIL_DYNAMIC_BITSET_HPP - -#include -#include -#include "boost/config.hpp" -#include "boost/detail/workaround.hpp" -#include - -#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64)) -#include -#endif - -namespace boost { - - namespace detail { - namespace dynamic_bitset_impl { - - template - struct max_limit { - BOOST_STATIC_CONSTEXPR T value = static_cast(-1); - }; - - template - BOOST_CONSTEXPR_OR_CONST T max_limit::value; - - // Gives (read-)access to the object representation - // of an object of type T (3.9p4). CANNOT be used - // on a base sub-object - // - template - inline const unsigned char * object_representation (T* p) - { - return static_cast(static_cast(p)); - } - - template - struct shifter - { - static void left_shift(T & v) { - amount >= width ? (v = 0) - : (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount)); - } - }; - - // ------- count function implementation -------------- - - typedef unsigned char byte_type; - - // These two entities - // - // enum mode { access_by_bytes, access_by_blocks }; - // template struct mode_to_type {}; - // - // were removed, since the regression logs (as of 24 Aug 2008) - // showed that several compilers had troubles with recognizing - // - // const mode m = access_by_bytes - // - // as a constant expression - // - // * So, we'll use bool, instead of enum *. - // - template - struct value_to_type - { - value_to_type() {} - }; - const bool access_by_bytes = true; - const bool access_by_blocks = false; - - - // the table: wrapped in a class template, so - // that it is only instantiated if/when needed - // - template - struct count_table { static const byte_type table[]; }; - - template <> - struct count_table { /* no table */ }; - - - const unsigned int table_width = 8; - template - const byte_type count_table::table[] = - { - // Automatically generated by GPTableGen.exe v.1.0 - // - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 - }; - - - // Some platforms have fast popcount operation, that allow us to implement - // counting bits much more efficiently - // - template - BOOST_FORCEINLINE std::size_t popcount(ValueType value) BOOST_NOEXCEPT - { - std::size_t num = 0u; - while (value) { - num += count_table<>::table[value & ((1u<>= table_width; - } - return num; - } - -#if (((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))) \ - && (defined(__POPCNT__) || defined(__AVX__)) - - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned short value) BOOST_NOEXCEPT - { - return static_cast(__popcnt16(value)); - } - - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned int value) BOOST_NOEXCEPT - { - return static_cast(__popcnt(value)); - } - - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned __int64 value) BOOST_NOEXCEPT - { -#if defined(_M_X64) - return static_cast(__popcnt64(value)); -#else - return static_cast(__popcnt(static_cast< unsigned int >(value))) + static_cast(__popcnt(static_cast< unsigned int >(value >> 32))); -#endif - } - -#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__)) - - // Note: gcc builtins are implemented by compiler runtime when the target CPU may not support the necessary instructions - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned short value) BOOST_NOEXCEPT - { - return static_cast(__builtin_popcount(static_cast(value))); - } - - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned int value) BOOST_NOEXCEPT - { - return static_cast(__builtin_popcount(value)); - } - - template <> - BOOST_FORCEINLINE std::size_t popcount(unsigned long value) BOOST_NOEXCEPT - { - return static_cast(__builtin_popcountl(value)); - } - - template <> - BOOST_FORCEINLINE std::size_t popcount(boost::ulong_long_type value) BOOST_NOEXCEPT - { - return static_cast(__builtin_popcountll(value)); - } - -#endif - - // overload for access by blocks - // - template - inline std::size_t do_count(Iterator first, std::size_t length, ValueType, - value_to_type*) - { - std::size_t num1 = 0u, num2 = 0u; - while (length >= 2u) { - num1 += popcount(*first); - ++first; - num2 += popcount(*first); - ++first; - length -= 2u; - } - - if (length > 0u) - num1 += popcount(*first); - - return num1 + num2; - } - - // overload for access by bytes - // - template - inline std::size_t do_count(Iterator first, std::size_t length, - int /*dummy param*/, - value_to_type*) - { - if (length > 0u) { - const byte_type* p = object_representation(&*first); - length *= sizeof(*first); - - return do_count(p, length, static_cast(0u), - static_cast< value_to_type* >(0)); - } - - return 0u; - } - - // ------------------------------------------------------- - - - // Some library implementations simply return a dummy - // value such as - // - // size_type(-1) / sizeof(T) - // - // from vector<>::max_size. This tries to get more - // meaningful info. - // - template - inline typename T::size_type vector_max_size_workaround(const T & v) - BOOST_NOEXCEPT - { - typedef typename T::allocator_type allocator_type; - - const allocator_type& alloc = v.get_allocator(); - - typename boost::allocator_size_type::type alloc_max = - boost::allocator_max_size(alloc); - - const typename T::size_type container_max = v.max_size(); - - return alloc_max < container_max ? alloc_max : container_max; - } - - // for static_asserts - template - struct allowed_block_type { - enum { value = T(-1) > 0 }; // ensure T has no sign - }; - - template <> - struct allowed_block_type { - enum { value = false }; - }; - - - template - struct is_numeric { - enum { value = false }; - }; - -# define BOOST_dynamic_bitset_is_numeric(x) \ - template<> \ - struct is_numeric< x > { \ - enum { value = true }; \ - } /**/ - - BOOST_dynamic_bitset_is_numeric(bool); - BOOST_dynamic_bitset_is_numeric(char); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_dynamic_bitset_is_numeric(wchar_t); -#endif - - BOOST_dynamic_bitset_is_numeric(signed char); - BOOST_dynamic_bitset_is_numeric(short int); - BOOST_dynamic_bitset_is_numeric(int); - BOOST_dynamic_bitset_is_numeric(long int); - - BOOST_dynamic_bitset_is_numeric(unsigned char); - BOOST_dynamic_bitset_is_numeric(unsigned short); - BOOST_dynamic_bitset_is_numeric(unsigned int); - BOOST_dynamic_bitset_is_numeric(unsigned long); - -#if defined(BOOST_HAS_LONG_LONG) - BOOST_dynamic_bitset_is_numeric(::boost::long_long_type); - BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type); -#endif - - // intentionally omitted - //BOOST_dynamic_bitset_is_numeric(float); - //BOOST_dynamic_bitset_is_numeric(double); - //BOOST_dynamic_bitset_is_numeric(long double); - -#undef BOOST_dynamic_bitset_is_numeric - - } // dynamic_bitset_impl - } // namespace detail - -} // namespace boost - -#endif // include guard - diff --git a/boost/flyweight/detail/archive_constructed.hpp b/boost/flyweight/detail/archive_constructed.hpp deleted file mode 100755 index 098f6271f8f93a30baa275cb6eaac4364abf7285..0000000000000000000000000000000000000000 --- a/boost/flyweight/detail/archive_constructed.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2006-2020 Joaquin M Lopez Munoz. - * 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) - * - * See http://www.boost.org/libs/flyweight for library home page. - */ - -#ifndef BOOST_FLYWEIGHT_DETAIL_ARCHIVE_CONSTRUCTED_HPP -#define BOOST_FLYWEIGHT_DETAIL_ARCHIVE_CONSTRUCTED_HPP - -#if defined(_MSC_VER)&&(_MSC_VER>=1200) -#pragma once -#endif - -#include /* keep it first to prevent nasty warns in MSVC */ -#include -#include -#include -#include -#include - -namespace boost{ - -namespace flyweights{ - -namespace detail{ - -/* constructs a stack-based object from a serialization archive */ - -template -struct archive_constructed:private noncopyable -{ - template - archive_constructed(Archive& ar,const unsigned int version) - { - serialization::load_construct_data_adl(ar,&get(),version); - BOOST_TRY{ - ar>>get(); - } - BOOST_CATCH(...){ - (&get())->~T(); - BOOST_RETHROW; - } - BOOST_CATCH_END - } - - template - archive_constructed(const char* name,Archive& ar,const unsigned int version) - { - serialization::load_construct_data_adl(ar,&get(),version); - BOOST_TRY{ - ar>>serialization::make_nvp(name,get()); - } - BOOST_CATCH(...){ - (&get())->~T(); - BOOST_RETHROW; - } - BOOST_CATCH_END - } - - ~archive_constructed() - { - (&get())->~T(); - } - - T& get(){return *static_cast(static_cast(&space));} - -private: - typename aligned_storage::value>::type space; -}; - -} /* namespace flyweights::detail */ - -} /* namespace flyweights */ - -} /* namespace boost */ - -#endif diff --git a/boost/fusion/view/filter_view/filter_view_iterator.hpp b/boost/fusion/view/filter_view/filter_view_iterator.hpp deleted file mode 100755 index 9280e72b4f2ef10ba0edd8e8fea39b1c0ce811a6..0000000000000000000000000000000000000000 --- a/boost/fusion/view/filter_view/filter_view_iterator.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - Copyright (c) 2018 Kohei Takahashi - - 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) -==============================================================================*/ -#if !defined(FUSION_FILTER_VIEW_ITERATOR_05062005_0849) -#define FUSION_FILTER_VIEW_ITERATOR_05062005_0849 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct filter_view_iterator_tag; - struct forward_traversal_tag; - - template - struct filter_iterator : iterator_base > - { - typedef convert_iterator first_converter; - typedef typename first_converter::type first_iter; - typedef convert_iterator last_converter; - typedef typename last_converter::type last_iter; - - typedef filter_view_iterator_tag fusion_tag; - typedef Category category; - typedef - detail::static_find_if< - first_iter - , last_iter - , mpl::bind1< - typename mpl::lambda::type - , mpl::bind1,mpl::_1> - > - > - filter; - typedef typename filter::type first_type; - typedef last_iter last_type; - typedef Pred pred_type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - filter_iterator(First const& in_first) - : first(filter::iter_call(first_converter::call(in_first))) {} - - first_type first; - - // silence MSVC warning C4512: assignment operator could not be generated - BOOST_DELETED_FUNCTION(filter_iterator& operator= (filter_iterator const&)) - }; -}} - -#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 -namespace std -{ - template - struct iterator_traits< ::boost::fusion::filter_iterator > - { }; -} -#endif - -#endif - - diff --git a/boost/geometry/arithmetic/dot_product.hpp b/boost/geometry/arithmetic/dot_product.hpp deleted file mode 100755 index 69214980dea049301ffc19f27a8a3cc25bf694eb..0000000000000000000000000000000000000000 --- a/boost/geometry/arithmetic/dot_product.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. - -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. - -// Use, modification and distribution is subject to 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) - -#ifndef BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP -#define BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP - - -#include - -#include - -#include -#include - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -template -struct dot_product_maker -{ - typedef typename select_coordinate_type::type coordinate_type; - - static inline coordinate_type apply(P1 const& p1, P2 const& p2) - { - return get(p1) * get(p2) - + dot_product_maker::apply(p1, p2); - } -}; - -template -struct dot_product_maker -{ - typedef typename select_coordinate_type::type coordinate_type; - - static inline coordinate_type apply(P1 const& p1, P2 const& p2) - { - return get(p1) * get(p2); - } -}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -/*! - \brief Computes the dot product (or scalar product) of 2 vectors (points). - \ingroup arithmetic - \tparam Point1 \tparam_point - \tparam Point2 \tparam_point - \param p1 first point - \param p2 second point - \return the dot product - - \qbk{[heading Examples]} - \qbk{[dot_product] [dot_product_output]} - - */ -template -inline typename select_coordinate_type::type dot_product( - Point1 const& p1, Point2 const& p2) -{ - BOOST_CONCEPT_ASSERT( (concepts::ConstPoint) ); - BOOST_CONCEPT_ASSERT( (concepts::ConstPoint) ); - - return detail::dot_product_maker - < - Point1, Point2, - 0, dimension::type::value - 1 - >::apply(p1, p2); -} - -}} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP diff --git a/boost/geometry/index/rtree.hpp b/boost/geometry/index/rtree.hpp deleted file mode 100755 index 471f19e04885f38691ffbc5b3c636806d3163aa0..0000000000000000000000000000000000000000 --- a/boost/geometry/index/rtree.hpp +++ /dev/null @@ -1,2419 +0,0 @@ -// Boost.Geometry Index -// -// R-tree implementation -// -// Copyright (c) 2008 Federico J. Fernandez. -// Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2020 Caian Benedicto, Campinas, Brazil. -// -// This file was modified by Oracle on 2019. -// Modifications copyright (c) 2019 Oracle and/or its affiliates. -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle -// -// Use, modification and distribution is subject to 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) - -#ifndef BOOST_GEOMETRY_INDEX_RTREE_HPP -#define BOOST_GEOMETRY_INDEX_RTREE_HPP - -// STD -#include - -// Boost -#include -#include -#include - -// Boost.Geometry -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// Boost.Geometry.Index -#include - -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -//#include - -#include - -#include - -#include - -#include -#include - -#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL -// serialization -#include -#endif - -// TODO change the name to bounding_tree - -/*! -\defgroup rtree_functions R-tree free functions (boost::geometry::index::) -*/ - -namespace boost { namespace geometry { namespace index { - -/*! -\brief The R-tree spatial index. - -This is self-balancing spatial index capable to store various types of Values -and balancing algorithms. - -\par Parameters -The user must pass a type defining the Parameters which will -be used in rtree creation process. This type is used e.g. to specify balancing -algorithm with specific parameters like min and max number of elements in node. - -\par -Predefined algorithms with compile-time parameters are: -\li boost::geometry::index::linear, - \li boost::geometry::index::quadratic, - \li boost::geometry::index::rstar. - -\par -Predefined algorithms with run-time parameters are: - \li \c boost::geometry::index::dynamic_linear, - \li \c boost::geometry::index::dynamic_quadratic, - \li \c boost::geometry::index::dynamic_rstar. - -\par IndexableGetter -The object of IndexableGetter type translates from Value to Indexable each time -r-tree requires it. This means that this operation is done for each Value -access. Therefore the IndexableGetter should return the Indexable by -a reference type. The Indexable should not be calculated since it could harm -the performance. The default IndexableGetter can translate all types adapted -to Point, Box or Segment concepts (called Indexables). Furthermore, it can -handle std::pair, boost::tuple -and std::tuple when possible. For example, for Value -of type std::pair, the default IndexableGetter translates -from std::pair const& to Box const&. - -\par EqualTo -The object of EqualTo type compares Values and returns true if they -are equal. It's similar to std::equal_to<>. The default EqualTo -returns the result of boost::geometry::equals() for types adapted to -some Geometry concept defined in Boost.Geometry and the result of -operator== for other types. Components of Pairs and Tuples are -compared left-to-right. - -\tparam Value The type of objects stored in the container. -\tparam Parameters Compile-time parameters. -\tparam IndexableGetter The function object extracting Indexable from Value. -\tparam EqualTo The function object comparing objects of type Value. -\tparam Allocator The allocator used to allocate/deallocate memory, - construct/destroy nodes and Values. -*/ -template -< - typename Value, - typename Parameters, - typename IndexableGetter = index::indexable, - typename EqualTo = index::equal_to, - typename Allocator = boost::container::new_allocator -> -class rtree -{ - BOOST_COPYABLE_AND_MOVABLE(rtree) - -public: - /*! \brief The type of Value stored in the container. */ - typedef Value value_type; - /*! \brief R-tree parameters type. */ - typedef Parameters parameters_type; - /*! \brief The function object extracting Indexable from Value. */ - typedef IndexableGetter indexable_getter; - /*! \brief The function object comparing objects of type Value. */ - typedef EqualTo value_equal; - /*! \brief The type of allocator used by the container. */ - typedef Allocator allocator_type; - - // TODO: SHOULD THIS TYPE BE REMOVED? - /*! \brief The Indexable type to which Value is translated. */ - typedef typename index::detail::indexable_type< - detail::translator - >::type indexable_type; - - /*! \brief The Box type used by the R-tree. */ - typedef geometry::model::box< - geometry::model::point< - typename coordinate_type::type, - dimension::value, - typename coordinate_system::type - > - > - bounds_type; - -private: - - typedef bounds_type box_type; - - struct members_holder - : public detail::translator - , public Parameters - , public detail::rtree::allocators - < - Allocator, - Value, - Parameters, - bounds_type, - typename detail::rtree::options_type::type::node_tag - > - { - typedef Value value_type; - typedef typename rtree::bounds_type bounds_type; - typedef Parameters parameters_type; - //typedef IndexableGetter indexable_getter; - //typedef EqualTo value_equal; - //typedef Allocator allocator_type; - - typedef bounds_type box_type; - typedef detail::translator translator_type; - typedef typename detail::rtree::options_type::type options_type; - typedef typename options_type::node_tag node_tag; - typedef detail::rtree::allocators - < - Allocator, Value, Parameters, bounds_type, node_tag - > allocators_type; - - typedef typename detail::rtree::node - < - value_type, parameters_type, bounds_type, allocators_type, node_tag - >::type node; - typedef typename detail::rtree::internal_node - < - value_type, parameters_type, bounds_type, allocators_type, node_tag - >::type internal_node; - typedef typename detail::rtree::leaf - < - value_type, parameters_type, bounds_type, allocators_type, node_tag - >::type leaf; - - // TODO: only one visitor type is needed - typedef typename detail::rtree::visitor - < - value_type, parameters_type, bounds_type, allocators_type, node_tag, false - >::type visitor; - typedef typename detail::rtree::visitor - < - value_type, parameters_type, bounds_type, allocators_type, node_tag, true - >::type visitor_const; - - typedef typename allocators_type::node_pointer node_pointer; - - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef typename allocators_type::size_type size_type; - - private: - members_holder(members_holder const&); - members_holder & operator=(members_holder const&); - - public: - template - members_holder(IndGet const& ind_get, - ValEq const& val_eq, - Parameters const& parameters, - BOOST_FWD_REF(Alloc) alloc) - : translator_type(ind_get, val_eq) - , Parameters(parameters) - , allocators_type(boost::forward(alloc)) - , values_count(0) - , leafs_level(0) - , root(0) - {} - - template - members_holder(IndGet const& ind_get, - ValEq const& val_eq, - Parameters const& parameters) - : translator_type(ind_get, val_eq) - , Parameters(parameters) - , allocators_type() - , values_count(0) - , leafs_level(0) - , root(0) - {} - - translator_type const& translator() const { return *this; } - - IndexableGetter const& indexable_getter() const { return *this; } - IndexableGetter & indexable_getter() { return *this; } - EqualTo const& equal_to() const { return *this; } - EqualTo & equal_to() { return *this; } - Parameters const& parameters() const { return *this; } - Parameters & parameters() { return *this; } - allocators_type const& allocators() const { return *this; } - allocators_type & allocators() { return *this; } - - size_type values_count; - size_type leafs_level; - node_pointer root; - }; - - typedef typename members_holder::translator_type translator_type; - typedef typename members_holder::options_type options_type; - typedef typename members_holder::allocators_type allocators_type; - typedef typename members_holder::node node; - typedef typename members_holder::internal_node internal_node; - typedef typename members_holder::leaf leaf; - - typedef typename members_holder::node_pointer node_pointer; - typedef typename members_holder::allocator_traits_type allocator_traits_type; - - friend class detail::rtree::utilities::view; -#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL - friend class detail::rtree::private_view; - friend class detail::rtree::const_private_view; -#endif - -public: - - /*! \brief Type of reference to Value. */ - typedef typename allocators_type::reference reference; - /*! \brief Type of reference to const Value. */ - typedef typename allocators_type::const_reference const_reference; - /*! \brief Type of pointer to Value. */ - typedef typename allocators_type::pointer pointer; - /*! \brief Type of pointer to const Value. */ - typedef typename allocators_type::const_pointer const_pointer; - /*! \brief Type of difference type. */ - typedef typename allocators_type::difference_type difference_type; - /*! \brief Unsigned integral type used by the container. */ - typedef typename allocators_type::size_type size_type; - - /*! \brief Type of const iterator, category ForwardIterator. */ - typedef index::detail::rtree::iterators::iterator - < - value_type, options_type, translator_type, box_type, allocators_type - > const_iterator; - - /*! \brief Type of const query iterator, category ForwardIterator. */ - typedef index::detail::rtree::iterators::query_iterator - < - value_type, allocators_type - > const_query_iterator; - -public: - - /*! - \brief The constructor. - - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - - \par Throws - If allocator default constructor throws. - */ - inline explicit rtree(parameters_type const& parameters = parameters_type(), - indexable_getter const& getter = indexable_getter(), - value_equal const& equal = value_equal()) - : m_members(getter, equal, parameters) - {} - - /*! - \brief The constructor. - - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - \param allocator The allocator object. - - \par Throws - If allocator copy constructor throws. - */ - inline rtree(parameters_type const& parameters, - indexable_getter const& getter, - value_equal const& equal, - allocator_type const& allocator) - : m_members(getter, equal, parameters, allocator) - {} - - /*! - \brief The constructor. - - The tree is created using packing algorithm. - - \param first The beginning of the range of Values. - \param last The end of the range of Values. - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - \param allocator The allocator object. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline rtree(Iterator first, Iterator last, - parameters_type const& parameters = parameters_type(), - indexable_getter const& getter = indexable_getter(), - value_equal const& equal = value_equal(), - allocator_type const& allocator = allocator_type()) - : m_members(getter, equal, parameters, allocator) - { - pack_construct(first, last, boost::container::new_allocator()); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm. - - \param rng The range of Values. - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - \param allocator The allocator object. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline explicit rtree(Range const& rng, - parameters_type const& parameters = parameters_type(), - indexable_getter const& getter = indexable_getter(), - value_equal const& equal = value_equal(), - allocator_type const& allocator = allocator_type()) - : m_members(getter, equal, parameters, allocator) - { - pack_construct(::boost::begin(rng), ::boost::end(rng), boost::container::new_allocator()); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param first The beginning of the range of Values. - \param last The end of the range of Values. - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - \param allocator The allocator object for persistent data in the tree. - \param temp_allocator The temporary allocator object used when packing. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline rtree(Iterator first, Iterator last, - parameters_type const& parameters, - indexable_getter const& getter, - value_equal const& equal, - allocator_type const& allocator, - PackAlloc const& temp_allocator) - : m_members(getter, equal, parameters, allocator) - { - pack_construct(first, last, temp_allocator); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param rng The range of Values. - \param parameters The parameters object. - \param getter The function object extracting Indexable from Value. - \param equal The function object comparing Values. - \param allocator The allocator object for persistent data in the tree. - \param temp_allocator The temporary allocator object used when packing. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline explicit rtree(Range const& rng, - parameters_type const& parameters, - indexable_getter const& getter, - value_equal const& equal, - allocator_type const& allocator, - PackAlloc const& temp_allocator) - : m_members(getter, equal, parameters, allocator) - { - pack_construct(::boost::begin(rng), ::boost::end(rng), temp_allocator); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param first The beginning of the range of Values. - \param last The end of the range of Values. - \param allocator The allocator object for persistent data in the tree. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline rtree(Iterator first, Iterator last, - allocator_type const& allocator) - : m_members(indexable_getter(), value_equal(), parameters_type(), allocator) - { - pack_construct(first, last, boost::container::new_allocator()); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param rng The range of Values. - \param allocator The allocator object for persistent data in the tree. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline explicit rtree(Range const& rng, - allocator_type const& allocator) - : m_members(indexable_getter(), value_equal(), parameters_type(), allocator) - { - pack_construct(::boost::begin(rng), ::boost::end(rng), boost::container::new_allocator()); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param first The beginning of the range of Values. - \param last The end of the range of Values. - \param allocator The allocator object for persistent data in the tree. - \param temp_allocator The temporary allocator object used when packing. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline rtree(Iterator first, Iterator last, - allocator_type const& allocator, - PackAlloc const& temp_allocator) - : m_members(indexable_getter(), value_equal(), parameters_type(), allocator) - { - pack_construct(first, last, temp_allocator); - } - - /*! - \brief The constructor. - - The tree is created using packing algorithm and a temporary packing allocator. - - \param rng The range of Values. - \param allocator The allocator object for persistent data in the tree. - \param temp_allocator The temporary allocator object used when packing. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline explicit rtree(Range const& rng, - allocator_type const& allocator, - PackAlloc const& temp_allocator) - : m_members(indexable_getter(), value_equal(), parameters_type(), allocator) - { - pack_construct(::boost::begin(rng), ::boost::end(rng), temp_allocator); - } - - /*! - \brief The destructor. - - \par Throws - Nothing. - */ - inline ~rtree() - { - this->raw_destroy(*this); - } - - /*! - \brief The copy constructor. - - It uses parameters, translator and allocator from the source tree. - - \param src The rtree which content will be copied. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor throws. - \li If allocation throws or returns invalid value. - */ - inline rtree(rtree const& src) - : m_members(src.m_members.indexable_getter(), - src.m_members.equal_to(), - src.m_members.parameters(), - allocator_traits_type::select_on_container_copy_construction(src.get_allocator())) - { - this->raw_copy(src, *this, false); - } - - /*! - \brief The copy constructor. - - It uses Parameters and translator from the source tree. - - \param src The rtree which content will be copied. - \param allocator The allocator which will be used. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor throws. - \li If allocation throws or returns invalid value. - */ - inline rtree(rtree const& src, allocator_type const& allocator) - : m_members(src.m_members.indexable_getter(), - src.m_members.equal_to(), - src.m_members.parameters(), allocator) - { - this->raw_copy(src, *this, false); - } - - /*! - \brief The moving constructor. - - It uses parameters, translator and allocator from the source tree. - - \param src The rtree which content will be moved. - - \par Throws - Nothing. - */ - inline rtree(BOOST_RV_REF(rtree) src) - : m_members(src.m_members.indexable_getter(), - src.m_members.equal_to(), - src.m_members.parameters(), - boost::move(src.m_members.allocators())) - { - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); - } - - /*! - \brief The moving constructor. - - It uses parameters and translator from the source tree. - - \param src The rtree which content will be moved. - \param allocator The allocator. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor throws (only if allocators aren't equal). - \li If allocation throws or returns invalid value (only if allocators aren't equal). - */ - inline rtree(BOOST_RV_REF(rtree) src, allocator_type const& allocator) - : m_members(src.m_members.indexable_getter(), - src.m_members.equal_to(), - src.m_members.parameters(), - allocator) - { - if ( src.m_members.allocators() == allocator ) - { - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); - } - else - { - this->raw_copy(src, *this, false); - } - } - - /*! - \brief The assignment operator. - - It uses parameters and translator from the source tree. - - \param src The rtree which content will be copied. - - \par Throws - \li If Value copy constructor throws. - \li If allocation throws. - \li If allocation throws or returns invalid value. - */ - inline rtree & operator=(BOOST_COPY_ASSIGN_REF(rtree) src) - { - if ( &src != this ) - { - allocators_type & this_allocs = m_members.allocators(); - allocators_type const& src_allocs = src.m_members.allocators(); - - // NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++ - // (allocators stored as base classes of members_holder) - // copying them changes values_count, in this case it doesn't cause errors since data must be copied - - typedef boost::mpl::bool_< - allocator_traits_type::propagate_on_container_copy_assignment::value - > propagate; - - if ( propagate::value && !(this_allocs == src_allocs) ) - this->raw_destroy(*this); - detail::assign_cond(this_allocs, src_allocs, propagate()); - - // It uses m_allocators - this->raw_copy(src, *this, true); - } - - return *this; - } - - /*! - \brief The moving assignment. - - It uses parameters and translator from the source tree. - - \param src The rtree which content will be moved. - - \par Throws - Only if allocators aren't equal. - \li If Value copy constructor throws. - \li If allocation throws or returns invalid value. - */ - inline rtree & operator=(BOOST_RV_REF(rtree) src) - { - if ( &src != this ) - { - allocators_type & this_allocs = m_members.allocators(); - allocators_type & src_allocs = src.m_members.allocators(); - - if ( this_allocs == src_allocs ) - { - this->raw_destroy(*this); - - m_members.indexable_getter() = src.m_members.indexable_getter(); - m_members.equal_to() = src.m_members.equal_to(); - m_members.parameters() = src.m_members.parameters(); - - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); - - // NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++ - // (allocators stored as base classes of members_holder) - // moving them changes values_count - - typedef boost::mpl::bool_< - allocator_traits_type::propagate_on_container_move_assignment::value - > propagate; - detail::move_cond(this_allocs, src_allocs, propagate()); - } - else - { -// TODO - shouldn't here propagate_on_container_copy_assignment be checked like in operator=(const&)? - - // It uses m_allocators - this->raw_copy(src, *this, true); - } - } - - return *this; - } - - /*! - \brief Swaps contents of two rtrees. - - Parameters, translator and allocators are swapped as well. - - \param other The rtree which content will be swapped with this rtree content. - - \par Throws - If allocators swap throws. - */ - void swap(rtree & other) - { - boost::swap(m_members.indexable_getter(), other.m_members.indexable_getter()); - boost::swap(m_members.equal_to(), other.m_members.equal_to()); - boost::swap(m_members.parameters(), other.m_members.parameters()); - - // NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++ - // (allocators stored as base classes of members_holder) - // swapping them changes values_count - - typedef boost::mpl::bool_< - allocator_traits_type::propagate_on_container_swap::value - > propagate; - detail::swap_cond(m_members.allocators(), other.m_members.allocators(), propagate()); - - boost::swap(m_members.values_count, other.m_members.values_count); - boost::swap(m_members.leafs_level, other.m_members.leafs_level); - boost::swap(m_members.root, other.m_members.root); - } - - /*! - \brief Insert a value to the index. - - \param value The value which will be stored in the container. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - inline void insert(value_type const& value) - { - if ( !m_members.root ) - this->raw_create(); - - this->raw_insert(value); - } - - /*! - \brief Insert a range of values to the index. - - \param first The beginning of the range of values. - \param last The end of the range of values. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - template - inline void insert(Iterator first, Iterator last) - { - if ( !m_members.root ) - this->raw_create(); - - for ( ; first != last ; ++first ) - this->raw_insert(*first); - } - - /*! - \brief Insert a value created using convertible object or a range of values to the index. - - \param conv_or_rng An object of type convertible to value_type or a range of values. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - template - inline void insert(ConvertibleOrRange const& conv_or_rng) - { - if ( !m_members.root ) - this->raw_create(); - - typedef boost::mpl::bool_ - < - boost::is_convertible::value - > is_conv_t; - - this->insert_dispatch(conv_or_rng, is_conv_t()); - } - - /*! - \brief Remove a value from the container. - - In contrast to the \c std::set or std::map erase() method - this method removes only one value from the container. - - \param value The value which will be removed from the container. - - \return 1 if the value was removed, 0 otherwise. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - inline size_type remove(value_type const& value) - { - if ( !m_members.root ) - return 0; - - return this->raw_remove(value); - } - - /*! - \brief Remove a range of values from the container. - - In contrast to the \c std::set or std::map erase() method - it doesn't take iterators pointing to values stored in this container. It removes values equal - to these passed as a range. Furthermore this method removes only one value for each one passed - in the range, not all equal values. - - \param first The beginning of the range of values. - \param last The end of the range of values. - - \return The number of removed values. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - template - inline size_type remove(Iterator first, Iterator last) - { - size_type result = 0; - - if ( !m_members.root ) - return result; - - for ( ; first != last ; ++first ) - result += this->raw_remove(*first); - return result; - } - - /*! - \brief Remove value corresponding to an object convertible to it or a range of values from the container. - - In contrast to the \c std::set or std::map erase() method - it removes values equal to these passed as a range. Furthermore, this method removes only - one value for each one passed in the range, not all equal values. - - \param conv_or_rng The object of type convertible to value_type or a range of values. - - \return The number of removed values. - - \par Throws - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - - \warning - This operation only guarantees that there will be no memory leaks. - After an exception is thrown the R-tree may be left in an inconsistent state, - elements must not be inserted or removed. Other operations are allowed however - some of them may return invalid data. - */ - template - inline size_type remove(ConvertibleOrRange const& conv_or_rng) - { - if ( !m_members.root ) - return 0; - - typedef boost::mpl::bool_ - < - boost::is_convertible::value - > is_conv_t; - - return this->remove_dispatch(conv_or_rng, is_conv_t()); - } - - /*! - \brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. - - This query function performs spatial and k-nearest neighbor searches. It allows to pass a set of predicates. - Values will be returned only if all predicates are met. - - Spatial predicates - - Spatial predicates may be generated by one of the functions listed below: - \li \c boost::geometry::index::contains(), - \li \c boost::geometry::index::covered_by(), - \li \c boost::geometry::index::covers(), - \li \c boost::geometry::index::disjoint(), - \li \c boost::geometry::index::intersects(), - \li \c boost::geometry::index::overlaps(), - \li \c boost::geometry::index::within(), - - It is possible to negate spatial predicates: - \li ! boost::geometry::index::contains(), - \li ! boost::geometry::index::covered_by(), - \li ! boost::geometry::index::covers(), - \li ! boost::geometry::index::disjoint(), - \li ! boost::geometry::index::intersects(), - \li ! boost::geometry::index::overlaps(), - \li ! boost::geometry::index::within() - - Satisfies predicate - - This is a special kind of predicate which allows to pass a user-defined function or function object which checks - if Value should be returned by the query. It's generated by: - \li \c boost::geometry::index::satisfies(). - - Nearest predicate - - If the nearest predicate is passed a k-nearest neighbor search will be performed. This query will result - in returning k values to the output iterator. Only one nearest predicate may be passed to the query. - It may be generated by: - \li \c boost::geometry::index::nearest(). - - Connecting predicates - - Predicates may be passed together connected with \c operator&&(). - - \par Example - \verbatim - // return elements intersecting box - tree.query(bgi::intersects(box), std::back_inserter(result)); - // return elements intersecting poly but not within box - tree.query(bgi::intersects(poly) && !bgi::within(box), std::back_inserter(result)); - // return elements overlapping box and meeting my_fun unary predicate - tree.query(bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); - // return 5 elements nearest to pt and elements are intersecting box - tree.query(bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); - - // For each found value do_something (it is a type of function object) - tree.query(bgi::intersects(box), - boost::make_function_output_iterator(do_something())); - - // For each value stored in the rtree do_something - // always_true is a type of function object always returning true - tree.query(bgi::satisfies(always_true()), - boost::make_function_output_iterator(do_something())); - - // C++11 (lambda expression) - tree.query(bgi::intersects(box), - boost::make_function_output_iterator([](value_type const& val){ - // do something - })); - - // C++14 (generic lambda expression) - tree.query(bgi::intersects(box), - boost::make_function_output_iterator([](auto const& val){ - // do something - })); - \endverbatim - - \par Throws - If Value copy constructor or copy assignment throws. - If predicates copy throws. - - \warning - Only one \c nearest() predicate may be passed to the query. Passing more of them results in compile-time error. - - \param predicates Predicates. - \param out_it The output iterator, e.g. generated by std::back_inserter(). - - \return The number of values found. - */ - template - size_type query(Predicates const& predicates, OutIter out_it) const - { - if ( !m_members.root ) - return 0; - - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; - static const bool is_distance_predicate = 0 < distance_predicates_count; - BOOST_MPL_ASSERT_MSG((distance_predicates_count <= 1), PASS_ONLY_ONE_DISTANCE_PREDICATE, (Predicates)); - - return query_dispatch(predicates, out_it, boost::mpl::bool_()); - } - - /*! - \brief Returns a query iterator pointing at the begin of the query range. - - This method returns an iterator which may be used to perform iterative queries. - For the information about predicates which may be passed to this method see query(). - - \par Example - \verbatim - for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; - it != tree.qend() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - - // C++11 (auto) - for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) - { - // do something with value - } - - // C++14 (generic lambda expression) - std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ - // do something with value - }); - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - If predicates copy throws. - If allocation throws. - - \warning - The modification of the rtree may invalidate the iterators. - - \param predicates Predicates. - - \return The iterator pointing at the begin of the query range. - */ - template - const_query_iterator qbegin(Predicates const& predicates) const - { - return const_query_iterator(qbegin_(predicates)); - } - - /*! - \brief Returns a query iterator pointing at the end of the query range. - - This method returns an iterator which may be used to check if the query has ended. - - \par Example - \verbatim - for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; - it != tree.qend() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - - // C++11 (auto) - for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) - { - // do something with value - } - - // C++14 (generic lambda expression) - std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ - // do something with value - }); - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - Nothing - - \warning - The modification of the rtree may invalidate the iterators. - - \return The iterator pointing at the end of the query range. - */ - const_query_iterator qend() const - { - return const_query_iterator(); - } - -#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL -private: -#endif - /*! - \brief Returns a query iterator pointing at the begin of the query range. - - This method returns an iterator which may be used to perform iterative queries. - For the information about predicates which may be passed to this method see query(). - - The type of the returned iterator depends on the type of passed Predicates but the iterator of this type - may be assigned to the variable of const_query_iterator type. If you'd like to use the type of the iterator - returned by this method you may get the type e.g. by using C++11 decltype or Boost.Typeof library. - This iterator may be compared with iterators returned by both versions of qend() method. - - \par Example - \verbatim - // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); - - // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend_(); - std::copy(first, last, std::back_inserter(result)); - - // Boost.Typeof - typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - - // C++11 (auto) - for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - If predicates copy throws. - If allocation throws. - - \warning - The modification of the rtree may invalidate the iterators. - - \param predicates Predicates. - - \return The iterator pointing at the begin of the query range. - */ - template - typename boost::mpl::if_c< - detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, - detail::rtree::iterators::distance_query_iterator< - members_holder, Predicates, - detail::predicates_find_distance::value - > - >::type - qbegin_(Predicates const& predicates) const - { - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; - BOOST_MPL_ASSERT_MSG((distance_predicates_count <= 1), PASS_ONLY_ONE_DISTANCE_PREDICATE, (Predicates)); - - typedef typename boost::mpl::if_c< - detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, - detail::rtree::iterators::distance_query_iterator< - members_holder, Predicates, - detail::predicates_find_distance::value - > - >::type iterator_type; - - if ( !m_members.root ) - return iterator_type(m_members.parameters(), m_members.translator(), predicates); - - return iterator_type(m_members.root, m_members.parameters(), m_members.translator(), predicates); - } - - /*! - \brief Returns the query iterator pointing at the end of the query range. - - This method returns the iterator which may be used to perform iterative queries. For the information - about the predicates which may be passed to this method see query(). - - The type of the returned iterator depends on the type of passed Predicates but the iterator of this type - may be assigned to the variable of const_query_iterator type. If you'd like to use the type of the iterator - returned by this method you may get the type e.g. by using C++11 decltype or Boost.Typeof library. - - The type of the iterator returned by this method is the same as the one returned by qbegin() to which - the same predicates were passed. - - \par Example - \verbatim - // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - If predicates copy throws. - - \warning - The modification of the rtree may invalidate the iterators. - - \param predicates Predicates. - - \return The iterator pointing at the end of the query range. - */ - template - typename boost::mpl::if_c< - detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, - detail::rtree::iterators::distance_query_iterator< - members_holder, Predicates, - detail::predicates_find_distance::value - > - >::type - qend_(Predicates const& predicates) const - { - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; - BOOST_MPL_ASSERT_MSG((distance_predicates_count <= 1), PASS_ONLY_ONE_DISTANCE_PREDICATE, (Predicates)); - - typedef typename boost::mpl::if_c< - detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, - detail::rtree::iterators::distance_query_iterator< - members_holder, Predicates, - detail::predicates_find_distance::value - > - >::type iterator_type; - - return iterator_type(m_members.parameters(), m_members.translator(), predicates); - } - - /*! - \brief Returns the query iterator pointing at the end of the query range. - - This method returns the iterator which may be compared with the iterator returned by qbegin() in order to - check if the query has ended. - - The type of the returned iterator is different than the type returned by qbegin() but the iterator of this type - may be assigned to the variable of const_query_iterator type. If you'd like to use the type of the iterator returned by this - method, which most certainly will be faster than the type-erased iterator, you may get the type - e.g. by using C++11 decltype or Boost.Typeof library. - - The type of the iterator returned by this method is different than the type returned by qbegin(). - - \par Example - \verbatim - // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend_(); - std::copy(first, last, std::back_inserter(result)); - - // Boost.Typeof - typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - - // C++11 (auto) - for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) - { - // do something with value - if ( has_enough_nearest_values() ) - break; - } - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - Nothing - - \warning - The modification of the rtree may invalidate the iterators. - - \return The iterator pointing at the end of the query range. - */ - detail::rtree::iterators::end_query_iterator - qend_() const - { - return detail::rtree::iterators::end_query_iterator(); - } - -public: - - /*! - \brief Returns the iterator pointing at the begin of the rtree values range. - - This method returns the iterator which may be used to iterate over all values - stored in the rtree. - - \par Example - \verbatim - // Copy all values into the vector - std::copy(tree.begin(), tree.end(), std::back_inserter(vec)); - - for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) - { - // do something with value - } - - // C++11 (auto) - for ( auto it = tree.begin() ; it != tree.end() ; ++it ) - { - // do something with value - } - - // C++14 (generic lambda expression) - std::for_each(tree.begin(), tree.end(), [](auto const& val){ - // do something with value - }) - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - If allocation throws. - - \warning - The modification of the rtree may invalidate the iterators. - - \return The iterator pointing at the begin of the range. - */ - const_iterator begin() const - { - if ( !m_members.root ) - return const_iterator(); - - return const_iterator(m_members.root); - } - - /*! - \brief Returns the iterator pointing at the end of the rtree values range. - - This method returns the iterator which may be compared with the iterator returned by begin() - in order to check if the iteration has ended. - - \par Example - \verbatim - for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) - { - // do something with value - } - - // C++11 (lambda expression) - std::for_each(tree.begin(), tree.end(), [](value_type const& val){ - // do something with value - }) - \endverbatim - - \par Iterator category - ForwardIterator - - \par Throws - Nothing. - - \warning - The modification of the rtree may invalidate the iterators. - - \return The iterator pointing at the end of the range. - */ - const_iterator end() const - { - return const_iterator(); - } - - /*! - \brief Returns the number of stored values. - - \return The number of stored values. - - \par Throws - Nothing. - */ - inline size_type size() const - { - return m_members.values_count; - } - - /*! - \brief Query if the container is empty. - - \return true if the container is empty. - - \par Throws - Nothing. - */ - inline bool empty() const - { - return 0 == m_members.values_count; - } - - /*! - \brief Removes all values stored in the container. - - \par Throws - Nothing. - */ - inline void clear() - { - this->raw_destroy(*this); - } - - /*! - \brief Returns the box able to contain all values stored in the container. - - Returns the box able to contain all values stored in the container. - If the container is empty the result of \c geometry::assign_inverse() is returned. - - \return The box able to contain all values stored in the container or an invalid box if - there are no values in the container. - - \par Throws - Nothing. - */ - inline bounds_type bounds() const - { - bounds_type result; - // in order to suppress the uninitialized variable warnings - geometry::assign_inverse(result); - - if ( m_members.root ) - { - detail::rtree::visitors::children_box - < - members_holder - > box_v(result, m_members.parameters(), m_members.translator()); - detail::rtree::apply_visitor(box_v, *m_members.root); - } - - return result; - } - - /*! - \brief Count Values or Indexables stored in the container. - - For indexable_type it returns the number of values which indexables equals the parameter. - For value_type it returns the number of values which equals the parameter. - - \param vori The value or indexable which will be counted. - - \return The number of values found. - - \par Throws - Nothing. - */ - template - size_type count(ValueOrIndexable const& vori) const - { - if ( !m_members.root ) - return 0; - - // the input should be convertible to Value or Indexable type - typedef typename index::detail::convertible_type - < - ValueOrIndexable, - value_type, - indexable_type - >::type value_or_indexable; - - static const bool is_void = boost::is_same::value; - BOOST_MPL_ASSERT_MSG((! is_void), - PASSED_OBJECT_NOT_CONVERTIBLE_TO_VALUE_NOR_INDEXABLE_TYPE, - (ValueOrIndexable)); - - // NOTE: If an object of convertible but not the same type is passed - // into the function, here a temporary will be created. - return this->template raw_count(vori); - } - - /*! - \brief Returns parameters. - - \return The parameters object. - - \par Throws - Nothing. - */ - inline parameters_type parameters() const - { - return m_members.parameters(); - } - - /*! - \brief Returns function retrieving Indexable from Value. - - \return The indexable_getter object. - - \par Throws - Nothing. - */ - indexable_getter indexable_get() const - { - return m_members.indexable_getter(); - } - - /*! - \brief Returns function comparing Values - - \return The value_equal function. - - \par Throws - Nothing. - */ - value_equal value_eq() const - { - return m_members.equal_to(); - } - - /*! - \brief Returns allocator used by the rtree. - - \return The allocator. - - \par Throws - If allocator copy constructor throws. - */ - allocator_type get_allocator() const - { - return m_members.allocators().allocator(); - } - -private: - - /*! - \brief Returns the translator object. - - \return The translator object. - - \par Throws - Nothing. - */ - inline translator_type translator() const - { - return m_members.translator(); - } - - /*! - \brief Apply a visitor to the nodes structure in order to perform some operator. - - This function is not a part of the 'official' interface. However it makes - possible e.g. to pass a visitor drawing the tree structure. - - \param visitor The visitor object. - - \par Throws - If Visitor::operator() throws. - */ - template - inline void apply_visitor(Visitor & visitor) const - { - if ( m_members.root ) - detail::rtree::apply_visitor(visitor, *m_members.root); - } - - /*! - \brief Returns the depth of the R-tree. - - This function is not a part of the 'official' interface. - - \return The depth of the R-tree. - - \par Throws - Nothing. - */ - inline size_type depth() const - { - return m_members.leafs_level; - } - -private: - - /*! - \pre Root node must exist - m_root != 0. - - \brief Insert a value to the index. - - \param value The value which will be stored in the container. - - \par Exception-safety - basic - */ - inline void raw_insert(value_type const& value) - { - BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - // CONSIDER: alternative - ignore invalid indexable or throw an exception - BOOST_GEOMETRY_INDEX_ASSERT(detail::is_valid(m_members.translator()(value)), "Indexable is invalid"); - - detail::rtree::visitors::insert - insert_v(m_members.root, m_members.leafs_level, value, - m_members.parameters(), m_members.translator(), m_members.allocators()); - - detail::rtree::apply_visitor(insert_v, *m_members.root); - -// TODO -// Think about this: If exception is thrown, may the root be removed? -// Or it is just cleared? - -// TODO -// If exception is thrown, m_values_count may be invalid - ++m_members.values_count; - } - - /*! - \brief Remove the value from the container. - - \param value The value which will be removed from the container. - - \par Exception-safety - basic - */ - inline size_type raw_remove(value_type const& value) - { - // TODO: awulkiew - assert for correct value (indexable) ? - BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - - detail::rtree::visitors::remove - remove_v(m_members.root, m_members.leafs_level, value, - m_members.parameters(), m_members.translator(), m_members.allocators()); - - detail::rtree::apply_visitor(remove_v, *m_members.root); - - // If exception is thrown, m_values_count may be invalid - - if ( remove_v.is_value_removed() ) - { - BOOST_GEOMETRY_INDEX_ASSERT(0 < m_members.values_count, "unexpected state"); - - --m_members.values_count; - - return 1; - } - - return 0; - } - - /*! - \brief Create an empty R-tree i.e. new empty root node and clear other attributes. - - \par Exception-safety - strong - */ - inline void raw_create() - { - BOOST_GEOMETRY_INDEX_ASSERT(0 == m_members.root, "the tree is already created"); - - m_members.root = detail::rtree::create_node::apply(m_members.allocators()); // MAY THROW (N: alloc) - m_members.values_count = 0; - m_members.leafs_level = 0; - } - - /*! - \brief Destroy the R-tree i.e. all nodes and clear attributes. - - \param t The container which is going to be destroyed. - - \par Exception-safety - nothrow - */ - inline void raw_destroy(rtree & t) - { - if ( t.m_members.root ) - { - detail::rtree::visitors::destroy - ::apply(t.m_members.root, t.m_members.allocators()); - - t.m_members.root = 0; - } - t.m_members.values_count = 0; - t.m_members.leafs_level = 0; - } - - /*! - \brief Copy the R-tree i.e. whole nodes structure, values and other attributes. - It uses destination's allocators to create the new structure. - - \param src The source R-tree. - \param dst The destination R-tree. - \param copy_tr_and_params If true, translator and parameters will also be copied. - - \par Exception-safety - strong - */ - inline void raw_copy(rtree const& src, rtree & dst, bool copy_tr_and_params) const - { - detail::rtree::visitors::copy copy_v(dst.m_members.allocators()); - - if ( src.m_members.root ) - detail::rtree::apply_visitor(copy_v, *src.m_members.root); // MAY THROW (V, E: alloc, copy, N: alloc) - - if ( copy_tr_and_params ) - { - dst.m_members.indexable_getter() = src.m_members.indexable_getter(); - dst.m_members.equal_to() = src.m_members.equal_to(); - dst.m_members.parameters() = src.m_members.parameters(); - } - - // TODO use subtree_destroyer - if ( dst.m_members.root ) - { - detail::rtree::visitors::destroy - ::apply(dst.m_members.root, dst.m_members.allocators()); - - dst.m_members.root = 0; - } - - dst.m_members.root = copy_v.result; - dst.m_members.values_count = src.m_members.values_count; - dst.m_members.leafs_level = src.m_members.leafs_level; - } - - /*! - \brief Insert a value corresponding to convertible object into the index. - - \param val_conv The object convertible to value. - - \par Exception-safety - basic - */ - template - inline void insert_dispatch(ValueConvertible const& val_conv, - boost::mpl::bool_ const& /*is_convertible*/) - { - this->raw_insert(val_conv); - } - - /*! - \brief Insert a range of values into the index. - - \param rng The range of values. - - \par Exception-safety - basic - */ - template - inline void insert_dispatch(Range const& rng, - boost::mpl::bool_ const& /*is_convertible*/) - { - BOOST_MPL_ASSERT_MSG((detail::is_range::value), - PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE, - (Range)); - - typedef typename boost::range_const_iterator::type It; - for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it ) - this->raw_insert(*it); - } - - /*! - \brief Remove a value corresponding to convertible object from the index. - - \param val_conv The object convertible to value. - - \par Exception-safety - basic - */ - template - inline size_type remove_dispatch(ValueConvertible const& val_conv, - boost::mpl::bool_ const& /*is_convertible*/) - { - return this->raw_remove(val_conv); - } - - /*! - \brief Remove a range of values from the index. - - \param rng The range of values which will be removed from the container. - - \par Exception-safety - basic - */ - template - inline size_type remove_dispatch(Range const& rng, - boost::mpl::bool_ const& /*is_convertible*/) - { - BOOST_MPL_ASSERT_MSG((detail::is_range::value), - PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE, - (Range)); - - size_type result = 0; - typedef typename boost::range_const_iterator::type It; - for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it ) - result += this->raw_remove(*it); - return result; - } - - /*! - \brief Return values meeting predicates. - - \par Exception-safety - strong - */ - template - size_type query_dispatch(Predicates const& predicates, OutIter out_it, boost::mpl::bool_ const& /*is_distance_predicate*/) const - { - detail::rtree::visitors::spatial_query - find_v(m_members.parameters(), m_members.translator(), predicates, out_it); - - detail::rtree::apply_visitor(find_v, *m_members.root); - - return find_v.found_count; - } - - /*! - \brief Perform nearest neighbour search. - - \par Exception-safety - strong - */ - template - size_type query_dispatch(Predicates const& predicates, OutIter out_it, boost::mpl::bool_ const& /*is_distance_predicate*/) const - { - BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - - static const unsigned distance_predicate_index = detail::predicates_find_distance::value; - detail::rtree::visitors::distance_query< - members_holder, - Predicates, - distance_predicate_index, - OutIter - > distance_v(m_members.parameters(), m_members.translator(), predicates, out_it); - - detail::rtree::apply_visitor(distance_v, *m_members.root); - - return distance_v.finish(); - } - - /*! - \brief Count elements corresponding to value or indexable. - - \par Exception-safety - strong - */ - template - size_type raw_count(ValueOrIndexable const& vori) const - { - BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - - detail::rtree::visitors::count - < - ValueOrIndexable, - members_holder - > count_v(vori, m_members.parameters(), m_members.translator()); - - detail::rtree::apply_visitor(count_v, *m_members.root); - - return count_v.found_count; - } - - /*! - \brief The constructor TODO. - - The tree is created using packing algorithm. - - \param first The beginning of the range of Values. - \param last The end of the range of Values. - \param temp_allocator The temporary allocator object to be used by the packing algorithm. - - \par Throws - \li If allocator copy constructor throws. - \li If Value copy constructor or copy assignment throws. - \li If allocation throws or returns invalid value. - */ - template - inline void pack_construct(Iterator first, Iterator last, PackAlloc const& temp_allocator) - { - typedef detail::rtree::pack pack; - size_type vc = 0, ll = 0; - m_members.root = pack::apply(first, last, vc, ll, - m_members.parameters(), m_members.translator(), - m_members.allocators(), temp_allocator); - m_members.values_count = vc; - m_members.leafs_level = ll; - } - - members_holder m_members; -}; - -/*! -\brief Insert a value to the index. - -It calls rtree::insert(value_type const&). - -\ingroup rtree_functions - -\param tree The spatial index. -\param v The value which will be stored in the index. -*/ -template -inline void insert(rtree & tree, - Value const& v) -{ - tree.insert(v); -} - -/*! -\brief Insert a range of values to the index. - -It calls rtree::insert(Iterator, Iterator). - -\ingroup rtree_functions - -\param tree The spatial index. -\param first The beginning of the range of values. -\param last The end of the range of values. -*/ -template -inline void insert(rtree & tree, - Iterator first, Iterator last) -{ - tree.insert(first, last); -} - -/*! -\brief Insert a value created using convertible object or a range of values to the index. - -It calls rtree::insert(ConvertibleOrRange const&). - -\ingroup rtree_functions - -\param tree The spatial index. -\param conv_or_rng The object of type convertible to value_type or a range of values. -*/ -template -inline void insert(rtree & tree, - ConvertibleOrRange const& conv_or_rng) -{ - tree.insert(conv_or_rng); -} - -/*! -\brief Remove a value from the container. - -Remove a value from the container. In contrast to the \c std::set or std::map erase() method -this function removes only one value from the container. - -It calls rtree::remove(value_type const&). - -\ingroup rtree_functions - -\param tree The spatial index. -\param v The value which will be removed from the index. - -\return 1 if value was removed, 0 otherwise. -*/ -template -inline typename rtree::size_type -remove(rtree & tree, - Value const& v) -{ - return tree.remove(v); -} - -/*! -\brief Remove a range of values from the container. - -Remove a range of values from the container. In contrast to the \c std::set or std::map erase() method -it doesn't take iterators pointing to values stored in this container. It removes values equal -to these passed as a range. Furthermore this function removes only one value for each one passed -in the range, not all equal values. - -It calls rtree::remove(Iterator, Iterator). - -\ingroup rtree_functions - -\param tree The spatial index. -\param first The beginning of the range of values. -\param last The end of the range of values. - -\return The number of removed values. -*/ -template -inline typename rtree::size_type -remove(rtree & tree, - Iterator first, Iterator last) -{ - return tree.remove(first, last); -} - -/*! -\brief Remove a value corresponding to an object convertible to it or a range of values from the container. - -Remove a value corresponding to an object convertible to it or a range of values from the container. -In contrast to the \c std::set or std::map erase() method -it removes values equal to these passed as a range. Furthermore this method removes only -one value for each one passed in the range, not all equal values. - -It calls rtree::remove(ConvertibleOrRange const&). - -\ingroup rtree_functions - -\param tree The spatial index. -\param conv_or_rng The object of type convertible to value_type or the range of values. - -\return The number of removed values. -*/ -template -inline typename rtree::size_type -remove(rtree & tree, - ConvertibleOrRange const& conv_or_rng) -{ - return tree.remove(conv_or_rng); -} - -/*! -\brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. - -This query function performs spatial and k-nearest neighbor searches. It allows to pass a set of predicates. -Values will be returned only if all predicates are met. - -Spatial predicates - -Spatial predicates may be generated by one of the functions listed below: -\li \c boost::geometry::index::contains(), -\li \c boost::geometry::index::covered_by(), -\li \c boost::geometry::index::covers(), -\li \c boost::geometry::index::disjoint(), -\li \c boost::geometry::index::intersects(), -\li \c boost::geometry::index::overlaps(), -\li \c boost::geometry::index::within(), - -It is possible to negate spatial predicates: -\li ! boost::geometry::index::contains(), -\li ! boost::geometry::index::covered_by(), -\li ! boost::geometry::index::covers(), -\li ! boost::geometry::index::disjoint(), -\li ! boost::geometry::index::intersects(), -\li ! boost::geometry::index::overlaps(), -\li ! boost::geometry::index::within() - -Satisfies predicate - -This is a special kind of predicate which allows to pass a user-defined function or function object which checks -if Value should be returned by the query. It's generated by: -\li \c boost::geometry::index::satisfies(). - -Nearest predicate - -If the nearest predicate is passed a k-nearest neighbor search will be performed. This query will result -in returning k values to the output iterator. Only one nearest predicate may be passed to the query. -It may be generated by: -\li \c boost::geometry::index::nearest(). - -Connecting predicates - -Predicates may be passed together connected with \c operator&&(). - -\par Example -\verbatim -// return elements intersecting box -bgi::query(tree, bgi::intersects(box), std::back_inserter(result)); -// return elements intersecting poly but not within box -bgi::query(tree, bgi::intersects(poly) && !bgi::within(box), std::back_inserter(result)); -// return elements overlapping box and meeting my_fun value predicate -bgi::query(tree, bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); -// return 5 elements nearest to pt and elements are intersecting box -bgi::query(tree, bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); - -// For each found value do_something (it is a type of function object) -tree.query(bgi::intersects(box), - boost::make_function_output_iterator(do_something())); -\endverbatim - -\par Throws -If Value copy constructor or copy assignment throws. - -\warning -Only one \c nearest() predicate may be passed to the query. Passing more of them results in compile-time error. - -\ingroup rtree_functions - -\param tree The rtree. -\param predicates Predicates. -\param out_it The output iterator, e.g. generated by std::back_inserter(). - -\return The number of values found. -*/ -template inline -typename rtree::size_type -query(rtree const& tree, - Predicates const& predicates, - OutIter out_it) -{ - return tree.query(predicates, out_it); -} - -/*! -\brief Returns the query iterator pointing at the begin of the query range. - -This method returns the iterator which may be used to perform iterative queries. For the information -about the predicates which may be passed to this method see query(). - -\par Example -\verbatim -std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); -\endverbatim - -\par Iterator category -ForwardIterator - -\par Throws -If predicates copy throws. -If allocation throws. - -\warning -The modification of the rtree may invalidate the iterators. - -\ingroup rtree_functions - -\param tree The rtree. -\param predicates Predicates. - -\return The iterator pointing at the begin of the query range. -*/ -template inline -typename rtree::const_query_iterator -qbegin(rtree const& tree, - Predicates const& predicates) -{ - return tree.qbegin(predicates); -} - -/*! -\brief Returns the query iterator pointing at the end of the query range. - -This method returns the iterator which may be used to check if the query has ended. - -\par Example -\verbatim -std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); -\endverbatim - -\par Iterator category -ForwardIterator - -\par Throws -Nothing - -\warning -The modification of the rtree may invalidate the iterators. - -\ingroup rtree_functions - -\return The iterator pointing at the end of the query range. -*/ -template inline -typename rtree::const_query_iterator -qend(rtree const& tree) -{ - return tree.qend(); -} - -/*! -\brief Returns the iterator pointing at the begin of the rtree values range. - -This method returns the iterator which may be used to iterate over all values -stored in the rtree. - -\par Example -\verbatim -std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); -// the same as -std::for_each(boost::begin(tree), boost::end(tree), do_something()); -\endverbatim - -\par Iterator category -ForwardIterator - -\par Throws -If allocation throws. - -\warning -The modification of the rtree may invalidate the iterators. - -\ingroup rtree_functions - -\return The iterator pointing at the begin of the range. -*/ -template inline -typename rtree::const_iterator -begin(rtree const& tree) -{ - return tree.begin(); -} - -/*! -\brief Returns the iterator pointing at the end of the rtree values range. - -This method returns the iterator which may be compared with the iterator returned by begin() -in order to check if the iteration has ended. - -\par Example -\verbatim -std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); -// the same as -std::for_each(boost::begin(tree), boost::end(tree), do_something()); -\endverbatim - -\par Iterator category -ForwardIterator - -\par Throws -Nothing. - -\warning -The modification of the rtree may invalidate the iterators. - -\ingroup rtree_functions - -\return The iterator pointing at the end of the range. -*/ -template inline -typename rtree::const_iterator -end(rtree const& tree) -{ - return tree.end(); -} - -/*! -\brief Remove all values from the index. - -It calls \c rtree::clear(). - -\ingroup rtree_functions - -\param tree The spatial index. -*/ -template -inline void clear(rtree & tree) -{ - return tree.clear(); -} - -/*! -\brief Get the number of values stored in the index. - -It calls \c rtree::size(). - -\ingroup rtree_functions - -\param tree The spatial index. - -\return The number of values stored in the index. -*/ -template -inline size_t size(rtree const& tree) -{ - return tree.size(); -} - -/*! -\brief Query if there are no values stored in the index. - -It calls \c rtree::empty(). - -\ingroup rtree_functions - -\param tree The spatial index. - -\return true if there are no values in the index. -*/ -template -inline bool empty(rtree const& tree) -{ - return tree.bounds(); -} - -/*! -\brief Get the box containing all stored values or an invalid box if the index has no values. - -It calls \c rtree::envelope(). - -\ingroup rtree_functions - -\param tree The spatial index. - -\return The box containing all stored values or an invalid box. -*/ -template -inline typename rtree::bounds_type -bounds(rtree const& tree) -{ - return tree.bounds(); -} - -/*! -\brief Exchanges the contents of the container with those of other. - -It calls \c rtree::swap(). - -\ingroup rtree_functions - -\param l The first rtree. -\param r The second rtree. -*/ -template -inline void swap(rtree & l, - rtree & r) -{ - return l.swap(r); -} - -}}} // namespace boost::geometry::index - -// Boost.Range adaptation -namespace boost { - -template -struct range_mutable_iterator - < - boost::geometry::index::rtree - > -{ - typedef typename boost::geometry::index::rtree - < - Value, Parameters, IndexableGetter, EqualTo, Allocator - >::const_iterator type; -}; - -} // namespace boost - -#include - -#endif // BOOST_GEOMETRY_INDEX_RTREE_HPP diff --git a/boost/gil/extension/dynamic_image/any_image.hpp b/boost/gil/extension/dynamic_image/any_image.hpp deleted file mode 100755 index 701fece6973c20c92c210b579efcd78eb23f0315..0000000000000000000000000000000000000000 --- a/boost/gil/extension/dynamic_image/any_image.hpp +++ /dev/null @@ -1,193 +0,0 @@ -// -// Copyright 2005-2007 Adobe Systems Incorporated -// Copyright 2020 Samuel Debionne -// -// 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 -// -#ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP -#define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP - -#include -#include - -#include -#include - -#include -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - -namespace boost { namespace gil { - -namespace detail { - -template -using get_view_t = typename T::view_t; - -template -using images_get_views_t = mp11::mp_transform; - -template -using get_const_view_t = typename T::const_view_t; - -template -using images_get_const_views_t = mp11::mp_transform; - -struct recreate_image_fnobj -{ - using result_type = void; - point const& _dimensions; - unsigned _alignment; - - recreate_image_fnobj(point const& dims, unsigned alignment) - : _dimensions(dims), _alignment(alignment) - {} - - template - result_type operator()(Image& img) const { img.recreate(_dimensions,_alignment); } -}; - -template // Models AnyViewConcept -struct any_image_get_view -{ - using result_type = AnyView; - template - result_type operator()(Image& img) const - { - return result_type(view(img)); - } -}; - -template // Models AnyConstViewConcept -struct any_image_get_const_view -{ - using result_type = AnyConstView; - template - result_type operator()(Image const& img) const { return result_type{const_view(img)}; } -}; - -} // namespce detail - -//////////////////////////////////////////////////////////////////////////////////////// -/// \ingroup ImageModel -/// \brief Represents a run-time specified image. Note it does NOT model ImageConcept -/// -/// Represents an image whose type (color space, layout, planar/interleaved organization, etc) can be specified at run time. -/// It is the runtime equivalent of \p image. -/// Some of the requirements of ImageConcept, such as the \p value_type alias cannot be fulfilled, since the language does not allow runtime type specification. -/// Other requirements, such as access to the pixels, would be inefficient to provide. Thus \p any_image does not fully model ImageConcept. -/// In particular, its \p view and \p const_view methods return \p any_image_view, which does not fully model ImageViewConcept. See \p any_image_view for more. -//////////////////////////////////////////////////////////////////////////////////////// - -template -class any_image : public variant2::variant -{ - using parent_t = variant2::variant; -public: - using view_t = mp11::mp_rename, any_image_view>; - using const_view_t = mp11::mp_rename, any_image_view>; - using x_coord_t = std::ptrdiff_t; - using y_coord_t = std::ptrdiff_t; - using point_t = point; - - any_image() = default; - any_image(any_image const& img) : parent_t((parent_t const&)img) {} - - template - explicit any_image(Image const& img) : parent_t(img) {} - - template - any_image(Image&& img) : parent_t(std::move(img)) {} - - template - explicit any_image(Image& img, bool do_swap) : parent_t(img, do_swap) {} - - template - any_image(any_image const& img) - : parent_t((variant2::variant const&)img) - {} - - any_image& operator=(any_image const& img) - { - parent_t::operator=((parent_t const&)img); - return *this; - } - - template - any_image& operator=(Image const& img) - { - parent_t::operator=(img); - return *this; - } - - template - any_image& operator=(any_image const& img) - { - parent_t::operator=((typename variant2::variant const&)img); - return *this; - } - - void recreate(const point_t& dims, unsigned alignment=1) - { - apply_operation(*this, detail::recreate_image_fnobj(dims, alignment)); - } - - void recreate(x_coord_t width, y_coord_t height, unsigned alignment=1) - { - recreate({ width, height }, alignment); - } - - std::size_t num_channels() const - { - return apply_operation(*this, detail::any_type_get_num_channels()); - } - - point_t dimensions() const - { - return apply_operation(*this, detail::any_type_get_dimensions()); - } - - x_coord_t width() const { return dimensions().x; } - y_coord_t height() const { return dimensions().y; } -}; - -///@{ -/// \name view, const_view -/// \brief Get an image view from a run-time instantiated image - -/// \ingroup ImageModel - -/// \brief Returns the non-constant-pixel view of any image. The returned view is any view. -/// \tparam Images Models ImageVectorConcept -template -BOOST_FORCEINLINE -auto view(any_image& img) -> typename any_image::view_t -{ - using view_t = typename any_image::view_t; - return apply_operation(img, detail::any_image_get_view()); -} - -/// \brief Returns the constant-pixel view of any image. The returned view is any view. -/// \tparam Types Models ImageVectorConcept -template -BOOST_FORCEINLINE -auto const_view(any_image const& img) -> typename any_image::const_view_t -{ - using view_t = typename any_image::const_view_t; - return apply_operation(img, detail::any_image_get_const_view()); -} -///@} - -}} // namespace boost::gil - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - -#endif diff --git a/boost/gil/extension/dynamic_image/dynamic_at_c.hpp b/boost/gil/extension/dynamic_image/dynamic_at_c.hpp deleted file mode 100755 index 37625e700d28e33b66bedf1d1ae4d65f53a1c753..0000000000000000000000000000000000000000 --- a/boost/gil/extension/dynamic_image/dynamic_at_c.hpp +++ /dev/null @@ -1,119 +0,0 @@ -// -// Copyright 2005-2007 Adobe Systems Incorporated -// -// 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 -// -#ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_DYNAMIC_AT_C_HPP -#define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_DYNAMIC_AT_C_HPP - -#include - -#include -#include - -#include - -namespace boost { namespace gil { - -// Constructs for static-to-dynamic integer convesion - -#define BOOST_GIL_AT_C_VALUE(z, N, text) mp11::mp_at_c::value, -#define BOOST_GIL_DYNAMIC_AT_C_LIMIT 226 // size of the maximum vector to handle - -#define BOOST_GIL_AT_C_LOOKUP(z, NUM, text) \ - template \ - struct at_c_fn { \ - template inline \ - static ValueType apply(std::size_t index) { \ - static ValueType table[] = { \ - BOOST_PP_REPEAT(NUM, BOOST_GIL_AT_C_VALUE, BOOST_PP_EMPTY) \ - }; \ - return table[index]; \ - } \ - }; - -namespace detail { - namespace at_c { - template struct at_c_fn; - BOOST_PP_REPEAT(BOOST_GIL_DYNAMIC_AT_C_LIMIT, BOOST_GIL_AT_C_LOOKUP, BOOST_PP_EMPTY) - - template struct at_c_impl; - - template <> - struct at_c_impl<0> { - template inline - static ValueType apply(std::size_t index) { - return at_c_fn<0, mp11::mp_size::value>::template apply(index); - } - }; - - template <> - struct at_c_impl<1> { - template inline - static ValueType apply(std::size_t index) { - const std::size_t SIZE = mp11::mp_size::value; - const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT; - switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) { - case 0: return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply(index); - case 1: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT); - }; - throw; - } - }; - - template <> - struct at_c_impl<2> { - template inline - static ValueType apply(std::size_t index) { - const std::size_t SIZE = mp11::mp_size::value; - const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT; - switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) { - case 0: return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply(index); - case 1: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT); - case 2: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*2); - }; - throw; - } - }; - - template <> - struct at_c_impl<3> { - template inline - static ValueType apply(std::size_t index) { - const std::size_t SIZE = mp11::mp_size::value; - const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT; - switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) { - case 0: return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply(index); - case 1: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT); - case 2: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*2); - case 3: return at_c_fn::template apply(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*3); - }; - throw; - } - }; - } -} - -//////////////////////////////////////////////////////////////////////////////////// -/// -/// \brief Given an Boost.MP11-compatible list and a dynamic index n, -/// returns the value of the n-th element. -/// It constructs a lookup table at compile time. -/// -//////////////////////////////////////////////////////////////////////////////////// - -template inline -ValueType at_c(std::size_t index) { - const std::size_t Size=mp11::mp_size::value; - return detail::at_c::at_c_impl::template apply(index); -} - -#undef BOOST_GIL_AT_C_VALUE -#undef BOOST_GIL_DYNAMIC_AT_C_LIMIT -#undef BOOST_GIL_AT_C_LOOKUP - -}} // namespace boost::gil - -#endif diff --git a/boost/gil/extension/numeric/resample.hpp b/boost/gil/extension/numeric/resample.hpp deleted file mode 100755 index 16f859113f73e17688b1d3bacde0aca18311be4f..0000000000000000000000000000000000000000 --- a/boost/gil/extension/numeric/resample.hpp +++ /dev/null @@ -1,143 +0,0 @@ -// -// Copyright 2005-2007 Adobe Systems Incorporated -// -// 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 -// -#ifndef BOOST_GIL_EXTENSION_NUMERIC_RESAMPLE_HPP -#define BOOST_GIL_EXTENSION_NUMERIC_RESAMPLE_HPP - -#include -#include - -#include -#include - -namespace boost { namespace gil { - -// Support for generic image resampling -// NOTE: The code is for example use only. It is not optimized for performance - -/////////////////////////////////////////////////////////////////////////// -//// -//// resample_pixels: set each pixel in the destination view as the result of a sampling function over the transformed coordinates of the source view -//// -/////////////////////////////////////////////////////////////////////////// - -template struct mapping_traits {}; - -/// \brief Set each pixel in the destination view as the result of a sampling function over the transformed coordinates of the source view -/// \ingroup ImageAlgorithms -/// -/// The provided implementation works for 2D image views only -template // Models MappingFunctionConcept -void resample_pixels(const SrcView& src_view, const DstView& dst_view, const MapFn& dst_to_src, Sampler sampler=Sampler()) -{ - typename DstView::point_t dst_dims=dst_view.dimensions(); - typename DstView::point_t dst_p; - - for (dst_p.y=0; dst_p.y - struct resample_pixels_fn : public binary_operation_obj > { - MapFn _dst_to_src; - Sampler _sampler; - resample_pixels_fn(const MapFn& dst_to_src, const Sampler& sampler) : _dst_to_src(dst_to_src), _sampler(sampler) {} - - template BOOST_FORCEINLINE void apply_compatible(const SrcView& src, const DstView& dst) const { - resample_pixels(src, dst, _dst_to_src, _sampler); - } - }; -} - -/// \brief resample_pixels when the source is run-time specified -/// If invoked on incompatible views, throws std::bad_cast() -/// \ingroup ImageAlgorithms -template -void resample_pixels(const any_image_view& src, const V2& dst, const MapFn& dst_to_src, Sampler sampler=Sampler()) -{ - apply_operation(src, std::bind( - detail::resample_pixels_fn(dst_to_src, sampler), - std::placeholders::_1, - dst)); -} - -/// \brief resample_pixels when the destination is run-time specified -/// If invoked on incompatible views, throws std::bad_cast() -/// \ingroup ImageAlgorithms -template -void resample_pixels(const V1& src, const any_image_view& dst, const MapFn& dst_to_src, Sampler sampler=Sampler()) -{ - using namespace std::placeholders; - apply_operation(dst, std::bind( - detail::resample_pixels_fn(dst_to_src, sampler), - src, - std::placeholders::_1)); -} - -/// \brief resample_pixels when both the source and the destination are run-time specified -/// If invoked on incompatible views, throws std::bad_cast() -/// \ingroup ImageAlgorithms -template -void resample_pixels(const any_image_view& src, const any_image_view& dst, const MapFn& dst_to_src, Sampler sampler=Sampler()) { - apply_operation(src,dst,detail::resample_pixels_fn(dst_to_src,sampler)); -} - -/////////////////////////////////////////////////////////////////////////// -//// -//// resample_subimage: copy into the destination a rotated rectangular region from the source, rescaling it to fit into the destination -//// -/////////////////////////////////////////////////////////////////////////// - -// Extract into dst the rotated bounds [src_min..src_max] rotated at 'angle' from the source view 'src' -// The source coordinates are in the coordinate space of the source image -// Note that the views could also be variants (i.e. any_image_view) -template -void resample_subimage(const SrcMetaView& src, const DstMetaView& dst, - double src_min_x, double src_min_y, - double src_max_x, double src_max_y, - double angle, const Sampler& sampler=Sampler()) { - double src_width = std::max(src_max_x - src_min_x - 1,1); - double src_height = std::max(src_max_y - src_min_y - 1,1); - double dst_width = std::max((double)(dst.width()-1),1); - double dst_height = std::max((double)(dst.height()-1),1); - - matrix3x2 mat = - matrix3x2::get_translate(-dst_width/2.0, -dst_height/2.0) * - matrix3x2::get_scale(src_width / dst_width, src_height / dst_height)* - matrix3x2::get_rotate(-angle)* - matrix3x2::get_translate(src_min_x + src_width/2.0, src_min_y + src_height/2.0); - resample_pixels(src,dst,mat,sampler); -} - -/////////////////////////////////////////////////////////////////////////// -//// -//// resize_view: Copy the source view into the destination, scaling to fit -//// -/////////////////////////////////////////////////////////////////////////// - -template -void resize_view(const SrcMetaView& src, const DstMetaView& dst, const Sampler& sampler=Sampler()) { - resample_subimage(src,dst,0.0,0.0,(double)src.width(),(double)src.height(),0.0,sampler); -} - -} } // namespace boost::gil - -#endif // BOOST_GIL_EXTENSION_NUMERIC_RESAMPLE_HPP diff --git a/boost/gil/promote_integral.hpp b/boost/gil/promote_integral.hpp deleted file mode 100755 index a12d341f7085ff0c5be7cd0f365d8886b2bfdd6b..0000000000000000000000000000000000000000 --- a/boost/gil/promote_integral.hpp +++ /dev/null @@ -1,199 +0,0 @@ -// Boost.GIL (Generic Image Library) -// -// Copyright (c) 2015, Oracle and/or its affiliates. -// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle -// -// Copyright (c) 2020, Debabrata Mandal -// -// Licensed under the Boost Software License version 1.0. -// http://www.boost.org/users/license.html -// -// Source: Boost.Geometry (aka GGL, Generic Geometry Library) -// Modifications: adapted for Boost.GIL -// - Rename namespace boost::geometry to boost::gil -// - Rename include guards -// - Remove support for boost::multiprecision types -// - Remove support for 128-bit integer types -// - Replace mpl meta functions with mp11 equivalents -// -#ifndef BOOST_GIL_PROMOTE_INTEGRAL_HPP -#define BOOST_GIL_PROMOTE_INTEGRAL_HPP - -#include - -#include -#include -#include - -namespace boost { namespace gil -{ - -namespace detail { namespace promote_integral -{ - -// meta-function that returns the bit size of a type -template -< - typename T, - bool IsFundamental = std::is_fundamental::value -> -struct bit_size {}; - -// for fundamental types, just return CHAR_BIT * sizeof(T) -template -struct bit_size : std::integral_constant {}; - -template -< - typename T, - typename IntegralTypes, - std::size_t MinSize -> -struct promote_to_larger -{ - using current_type = boost::mp11::mp_first; - using list_after_front = boost::mp11::mp_rest; - - using type = typename std::conditional - < - (bit_size::value >= MinSize), - current_type, - typename promote_to_larger - < - T, - list_after_front, - MinSize - >::type - >::type; -}; - -// The following specialization is required to finish the loop over -// all list elements -template -struct promote_to_larger, MinSize> -{ - // if promotion fails, keep the number T - // (and cross fingers that overflow will not occur) - using type = T; -}; - -}} // namespace detail::promote_integral - -/*! - \brief Meta-function to define an integral type with size - than is (roughly) twice the bit size of T - \ingroup utility - \details - This meta-function tries to promote the fundamental integral type T - to a another integral type with size (roughly) twice the bit size of T. - - To do this, two times the bit size of T is tested against the bit sizes of: - short, int, long, boost::long_long_type, boost::int128_t - and the one that first matches is chosen. - - For unsigned types the bit size of T is tested against the bit - sizes of the types above, if T is promoted to a signed type, or - the bit sizes of - unsigned short, unsigned int, unsigned long, std::size_t, - boost::ulong_long_type, boost::uint128_t - if T is promoted to an unsigned type. - - By default an unsigned type is promoted to a signed type. - This behavior is controlled by the PromoteUnsignedToUnsigned - boolean template parameter, whose default value is "false". - To promote an unsigned type to an unsigned type set the value of - this template parameter to "true". - - Finally, if the passed type is either a floating-point type or a - user-defined type it is returned as is. - - \note boost::long_long_type and boost::ulong_long_type are - considered only if the macro BOOST_HAS_LONG_LONG is defined - -*/ -template -< - typename T, - bool PromoteUnsignedToUnsigned = false, - bool UseCheckedInteger = false, - bool IsIntegral = std::is_integral::value -> -class promote_integral -{ -private: - static bool const is_unsigned = std::is_unsigned::value; - - using bit_size_type = detail::promote_integral::bit_size; - - // Define the minimum size (in bits) needed for the promoted type - // If T is the input type and P the promoted type, then the - // minimum number of bits for P are (below b stands for the number - // of bits of T): - // * if T is unsigned and P is unsigned: 2 * b - // * if T is signed and P is signed: 2 * b - 1 - // * if T is unsigned and P is signed: 2 * b + 1 - using min_bit_size_type = typename std::conditional - < - (PromoteUnsignedToUnsigned && is_unsigned), - std::integral_constant, - typename std::conditional - < - is_unsigned, - std::integral_constant, - std::integral_constant - >::type - >::type; - - // Define the list of signed integral types we are going to use - // for promotion - using signed_integral_types = boost::mp11::mp_list - < - short, int, long -#if defined(BOOST_HAS_LONG_LONG) - , boost::long_long_type -#endif - >; - - // Define the list of unsigned integral types we are going to use - // for promotion - using unsigned_integral_types = boost::mp11::mp_list - < - unsigned short, unsigned int, unsigned long, std::size_t -#if defined(BOOST_HAS_LONG_LONG) - , boost::ulong_long_type -#endif - >; - - // Define the list of integral types that will be used for - // promotion (depending in whether we was to promote unsigned to - // unsigned or not) - using integral_types = typename std::conditional - < - (is_unsigned && PromoteUnsignedToUnsigned), - unsigned_integral_types, - signed_integral_types - >::type; - -public: - using type = typename detail::promote_integral::promote_to_larger - < - T, - integral_types, - min_bit_size_type::value - >::type; -}; - - -template -class promote_integral - < - T, PromoteUnsignedToUnsigned, UseCheckedInteger, false - > -{ -public: - using type = T; -}; - -}} // namespace boost::gil - -#endif // BOOST_GIL_PROMOTE_INTEGRAL_HPP diff --git a/boost/multi_array/copy_array.hpp b/boost/multi_array/copy_array.hpp deleted file mode 100755 index a448d58bba4a03c1d6cef2203c5de92f0fd7a8b6..0000000000000000000000000000000000000000 --- a/boost/multi_array/copy_array.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2002 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Boost.MultiArray Library -// Authors: Ronald Garcia -// Jeremy Siek -// Andrew Lumsdaine -// See http://www.boost.org/libs/multi_array for documentation. - -#ifndef BOOST_MULTI_ARRAY_COPY_ARRAY_HPP -#define BOOST_MULTI_ARRAY_COPY_ARRAY_HPP - -// -// copy_array.hpp - generic code for copying the contents of one -// Basic_MultiArray to another. We assume that they are of the same -// shape -// -#include "boost/type.hpp" -#include "boost/assert.hpp" - -namespace boost { -namespace detail { -namespace multi_array { - -template -class copy_dispatch { -public: - template - static void copy_array (SourceIterator first, SourceIterator last, - DestIterator result) { - while (first != last) { - copy_array(*first++,*result++); - } - } -private: - // Array2 has to be passed by VALUE here because subarray - // pseudo-references are temporaries created by iterator::operator*() - template - static void copy_array (const Array1& source, Array2 dest) { - copy_array(source.begin(),source.end(),dest.begin()); - } - - static void copy_array (const Element& source, Element& dest) { - dest = source; - } - -}; - - -template -void copy_array (Array1& source, Array2& dest) { - BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(), - dest.shape())); - // Dispatch to the proper function - typedef typename Array1::element element_type; - copy_dispatch:: - copy_array(source.begin(),source.end(),dest.begin()); -} - - -} // namespace multi_array -} // namespace detail -} // namespace boost - -#endif diff --git a/boost/multi_array/extent_range.hpp b/boost/multi_array/extent_range.hpp deleted file mode 100755 index 1ee77438ed8e661169ce70a9f263124e0d3e8b27..0000000000000000000000000000000000000000 --- a/boost/multi_array/extent_range.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2002 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Boost.MultiArray Library -// Authors: Ronald Garcia -// Jeremy Siek -// Andrew Lumsdaine -// See http://www.boost.org/libs/multi_array for documentation. - -#ifndef BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP -#define BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP - -#include - -namespace boost { -namespace detail { -namespace multi_array { - -template -class extent_range : private std::pair { - typedef std::pair super_type; -public: - typedef Extent index; - typedef SizeType size_type; - - extent_range(index start, index finish) : - super_type(start,finish) { } - - extent_range(index finish) : - super_type(0,finish) { } - - extent_range() : super_type(0,0) { } - - index start() const { return super_type::first; } - - index finish() const { return super_type::second; } - - size_type size() const { return super_type::second - super_type::first; } -}; - -} // namespace multi_array -} // namespace detail -} // namespace boost - - -#endif diff --git a/boost/multi_array/range_list.hpp b/boost/multi_array/range_list.hpp deleted file mode 100755 index 46a65cb15365c5544d547de8fd13afdc5fd470b9..0000000000000000000000000000000000000000 --- a/boost/multi_array/range_list.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2002 The Trustees of Indiana University. - -// Use, modification and distribution is subject to 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) - -// Boost.MultiArray Library -// Authors: Ronald Garcia -// Jeremy Siek -// Andrew Lumsdaine -// See http://www.boost.org/libs/multi_array for documentation. - -#ifndef BOOST_MULTI_ARRAY_RANGE_LIST_HPP -#define BOOST_MULTI_ARRAY_RANGE_LIST_HPP -// -// range_list.hpp - helper to build boost::arrays for *_set types -// - -#include "boost/array.hpp" - -namespace boost { -namespace detail { -namespace multi_array { - -///////////////////////////////////////////////////////////////////////// -// choose range list begins -// - -struct choose_range_list_n { - template - struct bind { - typedef boost::array type; - }; -}; - -struct choose_range_list_zero { - template - struct bind { - typedef boost::array type; - }; -}; - - -template -struct range_list_gen_helper { - typedef choose_range_list_n choice; -}; - -template <> -struct range_list_gen_helper<0> { - typedef choose_range_list_zero choice; -}; - -template -struct range_list_generator { -private: - typedef typename range_list_gen_helper::choice Choice; -public: - typedef typename Choice::template bind::type type; -}; - -// -// choose range list ends -///////////////////////////////////////////////////////////////////////// - -} // namespace multi_array -} // namespace detail -} // namespace boost - -#endif diff --git a/boost/multiprecision/cpp_int/multiply.hpp b/boost/multiprecision/cpp_int/multiply.hpp deleted file mode 100755 index dd4d6a6f265a18d939b840972b253ccc02f8e911..0000000000000000000000000000000000000000 --- a/boost/multiprecision/cpp_int/multiply.hpp +++ /dev/null @@ -1,833 +0,0 @@ -/////////////////////////////////////////////////////////////// -// Copyright 2012-20 John Maddock. -// Copyright 2019-20 Christopher Kormanyos. -// Copyright 2019-20 Madhur Chauhan. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt -// -// Comparison operators for cpp_int_backend: -// -#ifndef BOOST_MP_CPP_INT_MUL_HPP -#define BOOST_MP_CPP_INT_MUL_HPP - -#include - -namespace boost { namespace multiprecision { namespace backends { - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant -#endif -// -// Multiplication by a single limb: -// -template -inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const limb_type& val) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - if (!val) - { - result = static_cast(0); - return; - } - if ((void*)&a != (void*)&result) - result.resize(a.size(), a.size()); - double_limb_type carry = 0; - typename cpp_int_backend::limb_pointer p = result.limbs(); - typename cpp_int_backend::limb_pointer pe = result.limbs() + result.size(); - typename cpp_int_backend::const_limb_pointer pa = a.limbs(); - while (p != pe) - { - carry += static_cast(*pa) * static_cast(val); -#ifdef __MSVC_RUNTIME_CHECKS - *p = static_cast(carry & ~static_cast(0)); -#else - *p = static_cast(carry); -#endif - carry >>= cpp_int_backend::limb_bits; - ++p, ++pa; - } - if (carry) - { - unsigned i = result.size(); - result.resize(i + 1, i + 1); - if (result.size() > i) - result.limbs()[i] = static_cast(carry); - } - result.sign(a.sign()); - if (is_fixed_precision >::value) - result.normalize(); -} - -// -// resize_for_carry forces a resize of the underlying buffer only if a previous request -// for "required" elements could possibly have failed, *and* we have checking enabled. -// This will cause an overflow error inside resize(): -// -template -inline BOOST_MP_CXX14_CONSTEXPR void resize_for_carry(cpp_int_backend& /*result*/, unsigned /*required*/) {} - -template -inline BOOST_MP_CXX14_CONSTEXPR void resize_for_carry(cpp_int_backend& result, unsigned required) -{ - if (result.size() < required) - result.resize(required, required); -} -// -// Minimum number of limbs required for Karatsuba to be worthwhile: -// -#ifdef BOOST_MP_KARATSUBA_CUTOFF -const size_t karatsuba_cutoff = BOOST_MP_KARATSUBA_CUTOFF; -#else -const size_t karatsuba_cutoff = 40; -#endif -// -// Core (recursive) Karatsuba multiplication, all the storage required is allocated upfront and -// passed down the stack in this routine. Note that all the cpp_int_backend's must be the same type -// and full variable precision. Karatsuba really doesn't play nice with fixed-size integers. If necessary -// fixed precision integers will get aliased as variable-precision types before this is called. -// -template -inline void multiply_karatsuba( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b, - typename cpp_int_backend::scoped_shared_storage& storage) -{ - typedef cpp_int_backend cpp_int_type; - - unsigned as = a.size(); - unsigned bs = b.size(); - // - // Termination condition: if either argument is smaller than karatsuba_cutoff - // then schoolboy multiplication will be faster: - // - if ((as < karatsuba_cutoff) || (bs < karatsuba_cutoff)) - { - eval_multiply(result, a, b); - return; - } - // - // Partitioning size: split the larger of a and b into 2 halves - // - unsigned n = (as > bs ? as : bs) / 2 + 1; - // - // Partition a and b into high and low parts. - // ie write a, b as a = a_h * 2^n + a_l, b = b_h * 2^n + b_l - // - // We could copy the high and low parts into new variables, but we'll - // use aliasing to reference the internal limbs of a and b. There is one wart here: - // if a and b are mismatched in size, then n may be larger than the smaller - // of a and b. In that situation the high part is zero, and we have no limbs - // to alias, so instead alias a local variable. - // This raises 2 questions: - // * Is this the best way to partition a and b? - // * Since we have one high part zero, the arithmetic simplifies considerably, - // so should we have a special routine for this? - // - unsigned sz = (std::min)(as, n); - const cpp_int_type a_l(a.limbs(), 0, sz); - - sz = (std::min)(bs, n); - const cpp_int_type b_l(b.limbs(), 0, sz); - - limb_type zero = 0; - const cpp_int_type a_h(as > n ? a.limbs() + n : &zero, 0, as > n ? as - n : 1); - const cpp_int_type b_h(bs > n ? b.limbs() + n : &zero, 0, bs > n ? bs - n : 1); - // - // The basis for the Karatsuba algorithm is as follows: - // - // let x = a_h * b_ h - // y = a_l * b_l - // z = (a_h + a_l)*(b_h + b_l) - x - y - // and therefore a * b = x * (2 ^ (2 * n))+ z * (2 ^ n) + y - // - // Begin by allocating our temporaries, these alias the memory already allocated in the shared storage: - // - cpp_int_type t1(storage, 2 * n + 2); - cpp_int_type t2(storage, n + 1); - cpp_int_type t3(storage, n + 1); - // - // Now we want: - // - // result = | a_h*b_h | a_l*b_l | - // (bits) <-- 2*n --> - // - // We create aliases for the low and high parts of result, and multiply directly into them: - // - cpp_int_type result_low(result.limbs(), 0, 2 * n); - cpp_int_type result_high(result.limbs(), 2 * n, result.size() - 2 * n); - // - // low part of result is a_l * b_l: - // - multiply_karatsuba(result_low, a_l, b_l, storage); - // - // We haven't zeroed out memory in result, so set to zero any unused limbs, - // if a_l and b_l have mostly random bits then nothing happens here, but if - // one is zero or nearly so, then a memset might be faster... it's not clear - // that it's worth the extra logic though (and is darn hard to measure - // what the "average" case is). - // - for (unsigned i = result_low.size(); i < 2 * n; ++i) - result.limbs()[i] = 0; - // - // Set the high part of result to a_h * b_h: - // - multiply_karatsuba(result_high, a_h, b_h, storage); - for (unsigned i = result_high.size() + 2 * n; i < result.size(); ++i) - result.limbs()[i] = 0; - // - // Now calculate (a_h+a_l)*(b_h+b_l): - // - add_unsigned(t2, a_l, a_h); - add_unsigned(t3, b_l, b_h); - multiply_karatsuba(t1, t2, t3, storage); // t1 = (a_h+a_l)*(b_h+b_l) - // - // There is now a slight deviation from Karatsuba, we want to subtract - // a_l*b_l + a_h*b_h from t1, but rather than use an addition and a subtraction - // plus one temporary, we'll use 2 subtractions. On the minus side, a subtraction - // is on average slightly slower than an addition, but we save a temporary (ie memory) - // and also hammer the same piece of memory over and over rather than 2 disparate - // memory regions. Overall it seems to be a slight win. - // - subtract_unsigned(t1, t1, result_high); - subtract_unsigned(t1, t1, result_low); - // - // The final step is to left shift t1 by n bits and add to the result. - // Rather than do an actual left shift, we can simply alias the result - // and add to the alias: - // - cpp_int_type result_alias(result.limbs(), n, result.size() - n); - add_unsigned(result_alias, result_alias, t1); - // - // Free up storage for use by sister branches to this one: - // - storage.deallocate(t1.capacity() + t2.capacity() + t3.capacity()); - - result.normalize(); -} - -inline unsigned karatsuba_storage_size(unsigned s) -{ - // - // This estimates how much memory we will need based on - // s-limb multiplication. In an ideal world the number of limbs - // would halve with each recursion, and our storage requirements - // would be 4s in the limit, and rather less in practice since - // we bail out long before we reach one limb. In the real world - // we don't quite halve s in each recursion, so this is an heuristic - // which over-estimates how much we need. We could compute an exact - // value, but it would be rather time consuming. - // - return 5 * s; -} -// -// There are 2 entry point routines for Karatsuba multiplication: -// one for variable precision types, and one for fixed precision types. -// These are responsible for allocating all the storage required for the recursive -// routines above, and are always at the outermost level. -// -// Normal variable precision case comes first: -// -template -inline typename enable_if_c >::value>::type -setup_karatsuba( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) -{ - unsigned as = a.size(); - unsigned bs = b.size(); - unsigned s = as > bs ? as : bs; - unsigned storage_size = karatsuba_storage_size(s); - if (storage_size < 300) - { - // - // Special case: if we don't need too much memory, we can use stack based storage - // and save a call to the allocator, this allows us to use Karatsuba multiply - // at lower limb counts than would otherwise be possible: - // - limb_type limbs[300]; - typename cpp_int_backend::scoped_shared_storage storage(limbs, storage_size); - multiply_karatsuba(result, a, b, storage); - } - else - { - typename cpp_int_backend::scoped_shared_storage storage(result.allocator(), storage_size); - multiply_karatsuba(result, a, b, storage); - } -} - -template -inline typename enable_if_c >::value || is_fixed_precision >::value || is_fixed_precision >::value>::type -setup_karatsuba( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) -{ - // - // Now comes the fixed precision case. - // In fact Karatsuba doesn't really work with fixed precision since the logic - // requires that we calculate all the bits of the result (especially in the - // temporaries used internally). So... we'll convert all the arguments - // to variable precision types by aliasing them, this also - // reduce the number of template instantations: - // - typedef cpp_int_backend<0, 0, signed_magnitude, unchecked, std::allocator > variable_precision_type; - variable_precision_type a_t(a.limbs(), 0, a.size()), b_t(b.limbs(), 0, b.size()); - unsigned as = a.size(); - unsigned bs = b.size(); - unsigned s = as > bs ? as : bs; - unsigned sz = as + bs; - unsigned storage_size = karatsuba_storage_size(s); - - if (sz * sizeof(limb_type) * CHAR_BIT <= MaxBits1) - { - // Result is large enough for all the bits of the result, so we can use aliasing: - result.resize(sz, sz); - variable_precision_type t(result.limbs(), 0, result.size()); - typename variable_precision_type::scoped_shared_storage storage(t.allocator(), storage_size); - multiply_karatsuba(t, a_t, b_t, storage); - } - else - { - // - // Not enough bit in result for the answer, so we must use a temporary - // and then truncate (ie modular arithmetic): - // - typename variable_precision_type::scoped_shared_storage storage(variable_precision_type::allocator_type(), sz + storage_size); - variable_precision_type t(storage, sz); - multiply_karatsuba(t, a_t, b_t, storage); - // - // If there is truncation, and result is a checked type then this will throw: - // - result = t; - } -} - -template -inline BOOST_MP_CXX14_CONSTEXPR void -eval_multiply_comba( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - // - // see PR #182 - // Comba Multiplier - based on Paul Comba's - // Exponentiation cryptosystems on the IBM PC, 1990 - // - int as = a.size(), - bs = b.size(), - rs = result.size(); - typename cpp_int_backend::limb_pointer pr = result.limbs(); - - double_limb_type carry = 0, - temp = 0; - limb_type overflow = 0; - const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT; - const bool must_throw = rs < as + bs - 1; - for (int r = 0, lim = (std::min)(rs, as + bs - 1); r < lim; ++r, overflow = 0) - { - int i = r >= as ? as - 1 : r, - j = r - i, - k = i < bs - j ? i + 1 : bs - j; // min(i+1, bs-j); - - typename cpp_int_backend::const_limb_pointer pa = a.limbs() + i; - typename cpp_int_backend::const_limb_pointer pb = b.limbs() + j; - - temp = carry; - carry += static_cast(*(pa)) * (*(pb)); - overflow += carry < temp; - for (--k; k; k--) - { - temp = carry; - carry += static_cast(*(--pa)) * (*(++pb)); - overflow += carry < temp; - } - *(pr++) = static_cast(carry); - carry = (static_cast(overflow) << limb_bits) | (carry >> limb_bits); - } - if (carry || must_throw) - { - resize_for_carry(result, as + bs); - if ((int)result.size() >= as + bs) - *pr = static_cast(carry); - } -} -template -inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) - BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value - && (karatsuba_cutoff * sizeof(limb_type) * CHAR_BIT > MaxBits1) - && (karatsuba_cutoff * sizeof(limb_type)* CHAR_BIT > MaxBits2) - && (karatsuba_cutoff * sizeof(limb_type)* CHAR_BIT > MaxBits3))) -{ - // Uses simple (O(n^2)) multiplication when the limbs are less - // otherwise switches to karatsuba algorithm based on experimental value (~40 limbs) - // - // Trivial cases first: - // - unsigned as = a.size(); - unsigned bs = b.size(); - typename cpp_int_backend::const_limb_pointer pa = a.limbs(); - typename cpp_int_backend::const_limb_pointer pb = b.limbs(); - if (as == 1) - { - bool s = b.sign() != a.sign(); - if (bs == 1) - { - result = static_cast(*pa) * static_cast(*pb); - } - else - { - limb_type l = *pa; - eval_multiply(result, b, l); - } - result.sign(s); - return; - } - if (bs == 1) - { - bool s = b.sign() != a.sign(); - limb_type l = *pb; - eval_multiply(result, a, l); - result.sign(s); - return; - } - - if ((void*)&result == (void*)&a) - { - cpp_int_backend t(a); - eval_multiply(result, t, b); - return; - } - if ((void*)&result == (void*)&b) - { - cpp_int_backend t(b); - eval_multiply(result, a, t); - return; - } - -#ifdef BOOST_NO_CXX14_CONSTEXPR - static const double_limb_type limb_max = ~static_cast(0u); - static const double_limb_type double_limb_max = ~static_cast(0u); -#else - constexpr const double_limb_type limb_max = ~static_cast(0u); - constexpr const double_limb_type double_limb_max = ~static_cast(0u); -#endif - result.resize(as + bs, as + bs - 1); -#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION - if (!BOOST_MP_IS_CONST_EVALUATED(as) && (as >= karatsuba_cutoff && bs >= karatsuba_cutoff)) -#else - if (as >= karatsuba_cutoff && bs >= karatsuba_cutoff) -#endif - { - setup_karatsuba(result, a, b); - // - // Set the sign of the result: - // - result.sign(a.sign() != b.sign()); - return; - } - typename cpp_int_backend::limb_pointer pr = result.limbs(); - BOOST_STATIC_ASSERT(double_limb_max - 2 * limb_max >= limb_max * limb_max); - -#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION - if (BOOST_MP_IS_CONST_EVALUATED(as)) - { - for (unsigned i = 0; i < result.size(); ++i) - pr[i] = 0; - } - else -#endif - std::memset(pr, 0, result.size() * sizeof(limb_type)); - -#if defined(BOOST_MP_COMBA) - // - // Comba Multiplier might not be efficient because of less efficient assembly - // by the compiler as of 09/01/2020 (DD/MM/YY). See PR #182 - // Till then this will lay dormant :( - // - eval_multiply_comba(result, a, b); -#else - - double_limb_type carry = 0; - for (unsigned i = 0; i < as; ++i) - { - BOOST_ASSERT(result.size() > i); - unsigned inner_limit = !is_fixed_precision >::value ? bs : (std::min)(result.size() - i, bs); - unsigned j = 0; - for (; j < inner_limit; ++j) - { - BOOST_ASSERT(i + j < result.size()); -#if (!defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || !BOOST_WORKAROUND(BOOST_GCC_VERSION, <= 50100) - BOOST_ASSERT(!std::numeric_limits::is_specialized || ((std::numeric_limits::max)() - carry > - static_cast(cpp_int_backend::max_limb_value) * static_cast(cpp_int_backend::max_limb_value))); -#endif - carry += static_cast(pa[i]) * static_cast(pb[j]); - BOOST_ASSERT(!std::numeric_limits::is_specialized || ((std::numeric_limits::max)() - carry >= pr[i + j])); - carry += pr[i + j]; -#ifdef __MSVC_RUNTIME_CHECKS - pr[i + j] = static_cast(carry & ~static_cast(0)); -#else - pr[i + j] = static_cast(carry); -#endif - carry >>= cpp_int_backend::limb_bits; - BOOST_ASSERT(carry <= (cpp_int_backend::max_limb_value)); - } - if (carry) - { - resize_for_carry(result, i + j + 1); // May throw if checking is enabled - if (i + j < result.size()) -#ifdef __MSVC_RUNTIME_CHECKS - pr[i + j] = static_cast(carry & ~static_cast(0)); -#else - pr[i + j] = static_cast(carry); -#endif - } - carry = 0; - } -#endif // ifdef(BOOST_MP_COMBA) ends - - result.normalize(); - // - // Set the sign of the result: - // - result.sign(a.sign() != b.sign()); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a) - BOOST_MP_NOEXCEPT_IF((noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval&>())))) -{ - eval_multiply(result, result, a); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value>::type -eval_multiply(cpp_int_backend& result, const limb_type& val) - BOOST_MP_NOEXCEPT_IF((noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval())))) -{ - eval_multiply(result, result, val); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const double_limb_type& val) - BOOST_MP_NOEXCEPT_IF( - (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval()))) - && (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval&>()))) - ) -{ - if (val <= (std::numeric_limits::max)()) - { - eval_multiply(result, a, static_cast(val)); - } - else - { -#if BOOST_ENDIAN_LITTLE_BYTE && !defined(BOOST_MP_TEST_NO_LE) - cpp_int_backend t(val); -#else - cpp_int_backend t; - t = val; -#endif - eval_multiply(result, a, t); - } -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value>::type -eval_multiply(cpp_int_backend& result, const double_limb_type& val) - BOOST_MP_NOEXCEPT_IF((noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval())))) -{ - eval_multiply(result, result, val); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const signed_limb_type& val) - BOOST_MP_NOEXCEPT_IF((noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval())))) -{ - if (val > 0) - eval_multiply(result, a, static_cast(val)); - else - { - eval_multiply(result, a, static_cast(boost::multiprecision::detail::unsigned_abs(val))); - result.negate(); - } -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value>::type -eval_multiply(cpp_int_backend& result, const signed_limb_type& val) - BOOST_MP_NOEXCEPT_IF((noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval())))) -{ - eval_multiply(result, result, val); -} - -template -inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value && !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const signed_double_limb_type& val) - BOOST_MP_NOEXCEPT_IF( - (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval()))) - && (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval&>()))) - ) -{ - if (val > 0) - { - if (val <= (std::numeric_limits::max)()) - { - eval_multiply(result, a, static_cast(val)); - return; - } - } - else if (val >= -static_cast((std::numeric_limits::max)())) - { - eval_multiply(result, a, static_cast(boost::multiprecision::detail::unsigned_abs(val))); - result.negate(); - return; - } -#if BOOST_ENDIAN_LITTLE_BYTE && !defined(BOOST_MP_TEST_NO_LE) - cpp_int_backend t(val); -#else - cpp_int_backend t; - t = val; -#endif - eval_multiply(result, a, t); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c >::value>::type -eval_multiply(cpp_int_backend& result, const signed_double_limb_type& val) - BOOST_MP_NOEXCEPT_IF( - (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval()))) - && (noexcept(eval_multiply(std::declval&>(), std::declval&>(), std::declval&>()))) - ) -{ - eval_multiply(result, result, val); -} - -// -// Now over again for trivial cpp_int's: -// -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - is_trivial_cpp_int >::value && is_trivial_cpp_int >::value && (is_signed_number >::value || is_signed_number >::value)>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - *result.limbs() = detail::checked_multiply(*result.limbs(), *o.limbs(), typename cpp_int_backend::checked_type()); - result.sign(result.sign() != o.sign()); - result.normalize(); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - is_trivial_cpp_int >::value && is_unsigned_number >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - *result.limbs() = detail::checked_multiply(*result.limbs(), *o.limbs(), typename cpp_int_backend::checked_type()); - result.normalize(); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - is_trivial_cpp_int >::value && is_trivial_cpp_int >::value && (is_signed_number >::value || is_signed_number >::value)>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - *result.limbs() = detail::checked_multiply(*a.limbs(), *b.limbs(), typename cpp_int_backend::checked_type()); - result.sign(a.sign() != b.sign()); - result.normalize(); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - is_trivial_cpp_int >::value && is_unsigned_number >::value>::type -eval_multiply( - cpp_int_backend& result, - const cpp_int_backend& a, - const cpp_int_backend& b) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int >::value)) -{ - *result.limbs() = detail::checked_multiply(*a.limbs(), *b.limbs(), typename cpp_int_backend::checked_type()); - result.normalize(); -} - -// -// Special routines for multiplying two integers to obtain a multiprecision result: -// -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - signed_double_limb_type a, signed_double_limb_type b) -{ -#ifdef BOOST_NO_CXX14_CONSTEXPR - static const signed_double_limb_type mask = ~static_cast(0); - static const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT; -#else - constexpr const signed_double_limb_type mask = ~static_cast(0); - constexpr const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT; -#endif - bool s = false; - if (a < 0) - { - a = -a; - s = true; - } - if (b < 0) - { - b = -b; - s = !s; - } - double_limb_type w = a & mask; - double_limb_type x = a >> limb_bits; - double_limb_type y = b & mask; - double_limb_type z = b >> limb_bits; - - result.resize(4, 4); - limb_type* pr = result.limbs(); - - double_limb_type carry = w * y; -#ifdef __MSVC_RUNTIME_CHECKS - pr[0] = static_cast(carry & ~static_cast(0)); - carry >>= limb_bits; - carry += w * z + x * y; - pr[1] = static_cast(carry & ~static_cast(0)); - carry >>= limb_bits; - carry += x * z; - pr[2] = static_cast(carry & ~static_cast(0)); - pr[3] = static_cast(carry >> limb_bits); -#else - pr[0] = static_cast(carry); - carry >>= limb_bits; - carry += w * z + x * y; - pr[1] = static_cast(carry); - carry >>= limb_bits; - carry += x * z; - pr[2] = static_cast(carry); - pr[3] = static_cast(carry >> limb_bits); -#endif - result.sign(s); - result.normalize(); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - !is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - double_limb_type a, double_limb_type b) -{ -#ifdef BOOST_NO_CXX14_CONSTEXPR - static const signed_double_limb_type mask = ~static_cast(0); - static const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT; -#else - constexpr const signed_double_limb_type mask = ~static_cast(0); - constexpr const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT; -#endif - - double_limb_type w = a & mask; - double_limb_type x = a >> limb_bits; - double_limb_type y = b & mask; - double_limb_type z = b >> limb_bits; - - result.resize(4, 4); - limb_type* pr = result.limbs(); - - double_limb_type carry = w * y; -#ifdef __MSVC_RUNTIME_CHECKS - pr[0] = static_cast(carry & ~static_cast(0)); - carry >>= limb_bits; - carry += w * z; - pr[1] = static_cast(carry & ~static_cast(0)); - carry >>= limb_bits; - pr[2] = static_cast(carry & ~static_cast(0)); - carry = x * y + pr[1]; - pr[1] = static_cast(carry & ~static_cast(0)); - carry >>= limb_bits; - carry += pr[2] + x * z; - pr[2] = static_cast(carry & ~static_cast(0)); - pr[3] = static_cast(carry >> limb_bits); -#else - pr[0] = static_cast(carry); - carry >>= limb_bits; - carry += w * z; - pr[1] = static_cast(carry); - carry >>= limb_bits; - pr[2] = static_cast(carry); - carry = x * y + pr[1]; - pr[1] = static_cast(carry); - carry >>= limb_bits; - carry += pr[2] + x * z; - pr[2] = static_cast(carry); - pr[3] = static_cast(carry >> limb_bits); -#endif - result.sign(false); - result.normalize(); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< - !is_trivial_cpp_int >::value && is_trivial_cpp_int >::value && is_trivial_cpp_int >::value>::type -eval_multiply( - cpp_int_backend& result, - cpp_int_backend const& a, - cpp_int_backend const& b) -{ - typedef typename boost::multiprecision::detail::canonical::local_limb_type, cpp_int_backend >::type canonical_type; - eval_multiply(result, static_cast(*a.limbs()), static_cast(*b.limbs())); - result.sign(a.sign() != b.sign()); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c::value && (sizeof(SI) <= sizeof(signed_double_limb_type) / 2)>::type -eval_multiply( - cpp_int_backend& result, - SI a, SI b) -{ - result = static_cast(a) * static_cast(b); -} - -template -BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename enable_if_c::value && (sizeof(UI) <= sizeof(signed_double_limb_type) / 2)>::type -eval_multiply( - cpp_int_backend& result, - UI a, UI b) -{ - result = static_cast(a) * static_cast(b); -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -}}} // namespace boost::multiprecision::backends - -#endif diff --git a/boost/nowide/utf/utf.hpp b/boost/nowide/utf/utf.hpp deleted file mode 100644 index eb0c625b7b7e901404e43dcf18b56a4833d9f1a9..0000000000000000000000000000000000000000 --- a/boost/nowide/utf/utf.hpp +++ /dev/null @@ -1,452 +0,0 @@ -// -// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) -// Copyright (c) 2020 Alexander Grund -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -#ifndef BOOST_NOWIDE_UTF_HPP_INCLUDED -#define BOOST_NOWIDE_UTF_HPP_INCLUDED - -#include -#include - -namespace boost { -namespace nowide { - /// - /// \brief Namespace that holds basic operations on UTF encoded sequences - /// - /// All functions defined in this namespace do not require linking with Boost.Nowide library - /// Extracted from Boost.Locale - /// - namespace utf { - - /// - /// \brief The integral type that can hold a Unicode code point - /// - typedef uint32_t code_point; - - /// - /// \brief Special constant that defines illegal code point - /// - static const code_point illegal = 0xFFFFFFFFu; - - /// - /// \brief Special constant that defines incomplete code point - /// - static const code_point incomplete = 0xFFFFFFFEu; - - /// - /// \brief the function checks if \a v is a valid code point - /// - inline bool is_valid_codepoint(code_point v) - { - if(v > 0x10FFFF) - return false; - if(0xD800 <= v && v <= 0xDFFF) // surrogates - return false; - return true; - } - -#ifdef BOOST_NOWIDE_DOXYGEN - /// - /// \brief UTF Traits class - functions to convert UTF sequences to and from Unicode code points - /// - template - struct utf_traits - { - /// - /// The type of the character - /// - typedef CharType char_type; - /// - /// Read one code point from the range [p,e) and return it. - /// - /// - If the sequence that was read is incomplete sequence returns \ref incomplete, - /// - If illegal sequence detected returns \ref illegal - /// - /// Requirements - /// - /// - Iterator is valid input iterator - /// - /// Postconditions - /// - /// - p points to the last consumed character - /// - template - static code_point decode(Iterator& p, Iterator e); - - /// - /// Maximal width of valid sequence in the code units: - /// - /// - UTF-8 - 4 - /// - UTF-16 - 2 - /// - UTF-32 - 1 - /// - static const int max_width; - /// - /// The width of specific code point in the code units. - /// - /// Requirement: value is a valid Unicode code point - /// Returns value in range [1..max_width] - /// - static int width(code_point value); - - /// - /// Get the size of the trail part of variable length encoded sequence. - /// - /// Returns -1 if C is not valid lead character - /// - static int trail_length(char_type c); - /// - /// Returns true if c is trail code unit, always false for UTF-32 - /// - static bool is_trail(char_type c); - /// - /// Returns true if c is lead code unit, always true of UTF-32 - /// - static bool is_lead(char_type c); - - /// - /// Convert valid Unicode code point \a value to the UTF sequence. - /// - /// Requirements: - /// - /// - \a value is valid code point - /// - \a out is an output iterator should be able to accept at least width(value) units - /// - /// Returns the iterator past the last written code unit. - /// - template - static Iterator encode(code_point value, Iterator out); - /// - /// Decodes valid UTF sequence that is pointed by p into code point. - /// - /// If the sequence is invalid or points to end the behavior is undefined - /// - template - static code_point decode_valid(Iterator& p); - }; - -#else - - template - struct utf_traits; - - template - struct utf_traits - { - typedef CharType char_type; - - static int trail_length(char_type ci) - { - unsigned char c = ci; - if(c < 128) - return 0; - if(BOOST_UNLIKELY(c < 194)) - return -1; - if(c < 224) - return 1; - if(c < 240) - return 2; - if(BOOST_LIKELY(c <= 244)) - return 3; - return -1; - } - - static const int max_width = 4; - - static int width(code_point value) - { - if(value <= 0x7F) - { - return 1; - } else if(value <= 0x7FF) - { - return 2; - } else if(BOOST_LIKELY(value <= 0xFFFF)) - { - return 3; - } else - { - return 4; - } - } - - static bool is_trail(char_type ci) - { - unsigned char c = ci; - return (c & 0xC0) == 0x80; - } - - static bool is_lead(char_type ci) - { - return !is_trail(ci); - } - - template - static code_point decode(Iterator& p, Iterator e) - { - if(BOOST_UNLIKELY(p == e)) - return incomplete; - - unsigned char lead = *p++; - - // First byte is fully validated here - int trail_size = trail_length(lead); - - if(BOOST_UNLIKELY(trail_size < 0)) - return illegal; - - // OK as only ASCII may be of size = 0 - // also optimize for ASCII text - if(trail_size == 0) - return lead; - - code_point c = lead & ((1 << (6 - trail_size)) - 1); - - // Read the rest - unsigned char tmp; - switch(trail_size) - { - case 3: - if(BOOST_UNLIKELY(p == e)) - return incomplete; - tmp = *p++; - if(!is_trail(tmp)) - return illegal; - c = (c << 6) | (tmp & 0x3F); - BOOST_NOWIDE_FALLTHROUGH; - case 2: - if(BOOST_UNLIKELY(p == e)) - return incomplete; - tmp = *p++; - if(!is_trail(tmp)) - return illegal; - c = (c << 6) | (tmp & 0x3F); - BOOST_NOWIDE_FALLTHROUGH; - case 1: - if(BOOST_UNLIKELY(p == e)) - return incomplete; - tmp = *p++; - if(!is_trail(tmp)) - return illegal; - c = (c << 6) | (tmp & 0x3F); - } - - // Check code point validity: no surrogates and - // valid range - if(BOOST_UNLIKELY(!is_valid_codepoint(c))) - return illegal; - - // make sure it is the most compact representation - if(BOOST_UNLIKELY(width(c) != trail_size + 1)) - return illegal; - - return c; - } - - template - static code_point decode_valid(Iterator& p) - { - unsigned char lead = *p++; - if(lead < 192) - return lead; - - int trail_size; - - if(lead < 224) - trail_size = 1; - else if(BOOST_LIKELY(lead < 240)) // non-BMP rare - trail_size = 2; - else - trail_size = 3; - - code_point c = lead & ((1 << (6 - trail_size)) - 1); - - switch(trail_size) - { - case 3: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH; - case 2: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH; - case 1: c = (c << 6) | (static_cast(*p++) & 0x3F); - } - - return c; - } - - template - static Iterator encode(code_point value, Iterator out) - { - if(value <= 0x7F) - { - *out++ = static_cast(value); - } else if(value <= 0x7FF) - { - *out++ = static_cast((value >> 6) | 0xC0); - *out++ = static_cast((value & 0x3F) | 0x80); - } else if(BOOST_LIKELY(value <= 0xFFFF)) - { - *out++ = static_cast((value >> 12) | 0xE0); - *out++ = static_cast(((value >> 6) & 0x3F) | 0x80); - *out++ = static_cast((value & 0x3F) | 0x80); - } else - { - *out++ = static_cast((value >> 18) | 0xF0); - *out++ = static_cast(((value >> 12) & 0x3F) | 0x80); - *out++ = static_cast(((value >> 6) & 0x3F) | 0x80); - *out++ = static_cast((value & 0x3F) | 0x80); - } - return out; - } - }; // utf8 - - template - struct utf_traits - { - typedef CharType char_type; - - // See RFC 2781 - static bool is_first_surrogate(uint16_t x) - { - return 0xD800 <= x && x <= 0xDBFF; - } - static bool is_second_surrogate(uint16_t x) - { - return 0xDC00 <= x && x <= 0xDFFF; - } - static code_point combine_surrogate(uint16_t w1, uint16_t w2) - { - return ((code_point(w1 & 0x3FF) << 10) | (w2 & 0x3FF)) + 0x10000; - } - static int trail_length(char_type c) - { - if(is_first_surrogate(c)) - return 1; - if(is_second_surrogate(c)) - return -1; - return 0; - } - /// - /// Returns true if c is trail code unit, always false for UTF-32 - /// - static bool is_trail(char_type c) - { - return is_second_surrogate(c); - } - /// - /// Returns true if c is lead code unit, always true of UTF-32 - /// - static bool is_lead(char_type c) - { - return !is_second_surrogate(c); - } - - template - static code_point decode(It& current, It last) - { - if(BOOST_UNLIKELY(current == last)) - return incomplete; - uint16_t w1 = *current++; - if(BOOST_LIKELY(w1 < 0xD800 || 0xDFFF < w1)) - { - return w1; - } - if(w1 > 0xDBFF) - return illegal; - if(current == last) - return incomplete; - uint16_t w2 = *current++; - if(w2 < 0xDC00 || 0xDFFF < w2) - return illegal; - return combine_surrogate(w1, w2); - } - template - static code_point decode_valid(It& current) - { - uint16_t w1 = *current++; - if(BOOST_LIKELY(w1 < 0xD800 || 0xDFFF < w1)) - { - return w1; - } - uint16_t w2 = *current++; - return combine_surrogate(w1, w2); - } - - static const int max_width = 2; - static int width(code_point u) - { - return u >= 0x10000 ? 2 : 1; - } - template - static It encode(code_point u, It out) - { - if(BOOST_LIKELY(u <= 0xFFFF)) - { - *out++ = static_cast(u); - } else - { - u -= 0x10000; - *out++ = static_cast(0xD800 | (u >> 10)); - *out++ = static_cast(0xDC00 | (u & 0x3FF)); - } - return out; - } - }; // utf16; - - template - struct utf_traits - { - typedef CharType char_type; - static int trail_length(char_type c) - { - if(is_valid_codepoint(c)) - return 0; - return -1; - } - static bool is_trail(char_type /*c*/) - { - return false; - } - static bool is_lead(char_type /*c*/) - { - return true; - } - - template - static code_point decode_valid(It& current) - { - return *current++; - } - - template - static code_point decode(It& current, It last) - { - if(BOOST_UNLIKELY(current == last)) - return incomplete; - code_point c = *current++; - if(BOOST_UNLIKELY(!is_valid_codepoint(c))) - return illegal; - return c; - } - static const int max_width = 1; - static int width(code_point /*u*/) - { - return 1; - } - template - static It encode(code_point u, It out) - { - *out++ = static_cast(u); - return out; - } - - }; // utf32 - -#endif - - } // namespace utf -} // namespace nowide -} // namespace boost - -#endif diff --git a/boost/outcome/bad_access.hpp b/boost/outcome/bad_access.hpp deleted file mode 100755 index 5a98cbbb16442b236e5f3f1bf01171ecf9b4ba7c..0000000000000000000000000000000000000000 --- a/boost/outcome/bad_access.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* Exception types throwable -(C) 2017-2020 Niall Douglas (9 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BAD_ACCESS_HPP -#define BOOST_OUTCOME_BAD_ACCESS_HPP - -#include "config.hpp" - -#include - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -/*! AWAITING HUGO JSON CONVERSION TOOL -type definition bad_result_access. Potential doc page: `bad_result_access` -*/ -class BOOST_OUTCOME_SYMBOL_VISIBLE bad_result_access : public std::logic_error -{ -public: - explicit bad_result_access(const char *what) - : std::logic_error(what) - { - } -}; - -/*! AWAITING HUGO JSON CONVERSION TOOL -type definition template bad_result_access_with. Potential doc page: `bad_result_access_with` -*/ -template class BOOST_OUTCOME_SYMBOL_VISIBLE bad_result_access_with : public bad_result_access -{ - S _error; - -public: - explicit bad_result_access_with(S v) - : bad_result_access("no value") - , _error(std::move(v)) - { - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - const S &error() const & { return _error; } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - S &error() & { return _error; } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - const S &&error() const && { return _error; } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - S &&error() && { return _error; } -}; - -/*! AWAITING HUGO JSON CONVERSION TOOL -type definition bad_outcome_access. Potential doc page: `bad_outcome_access` -*/ -class BOOST_OUTCOME_SYMBOL_VISIBLE bad_outcome_access : public std::logic_error -{ -public: - explicit bad_outcome_access(const char *what) - : std::logic_error(what) - { - } -}; - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/basic_outcome.hpp b/boost/outcome/basic_outcome.hpp deleted file mode 100755 index 79c472a194ed95e375aa3445be0e939370d1403e..0000000000000000000000000000000000000000 --- a/boost/outcome/basic_outcome.hpp +++ /dev/null @@ -1,1202 +0,0 @@ -/* A less simple result type -(C) 2017-2020 Niall Douglas (20 commits) -File Created: June 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BASIC_OUTCOME_HPP -#define BOOST_OUTCOME_BASIC_OUTCOME_HPP - -#include "config.hpp" - -#include "basic_result.hpp" -#include "detail/basic_outcome_exception_observers.hpp" -#include "detail/basic_outcome_failure_observers.hpp" - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdocumentation" // Standardese markup confuses clang -#endif - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -template // -class basic_outcome; - -namespace detail -{ - // May be reused by basic_outcome subclasses to save load on the compiler - template struct outcome_predicates - { - using result = result_predicates; - - // Predicate for the implicit constructors to be available - static constexpr bool implicit_constructors_enabled = // - result::implicit_constructors_enabled // - && !detail::is_implicitly_constructible // - && !detail::is_implicitly_constructible // - && !detail::is_implicitly_constructible // - && !detail::is_implicitly_constructible; - - // Predicate for the value converting constructor to be available. - template - static constexpr bool enable_value_converting_constructor = // - implicit_constructors_enabled // - &&result::template enable_value_converting_constructor // - && !detail::is_implicitly_constructible; // deliberately less tolerant of ambiguity than result's edition - - // Predicate for the error converting constructor to be available. - template - static constexpr bool enable_error_converting_constructor = // - implicit_constructors_enabled // - &&result::template enable_error_converting_constructor // - && !detail::is_implicitly_constructible; // deliberately less tolerant of ambiguity than result's edition - - // Predicate for the error condition converting constructor to be available. - template - static constexpr bool enable_error_condition_converting_constructor = result::template enable_error_condition_converting_constructor // - && !detail::is_implicitly_constructible; - - // Predicate for the exception converting constructor to be available. - template - static constexpr bool enable_exception_converting_constructor = // - implicit_constructors_enabled // - && !is_in_place_type_t>::value // not in place construction - && !detail::is_implicitly_constructible && !detail::is_implicitly_constructible && - detail::is_implicitly_constructible; - - // Predicate for the error + exception converting constructor to be available. - template - static constexpr bool enable_error_exception_converting_constructor = // - implicit_constructors_enabled // - && !is_in_place_type_t>::value // not in place construction - && !detail::is_implicitly_constructible && detail::is_implicitly_constructible // - && !detail::is_implicitly_constructible && detail::is_implicitly_constructible; - - // Predicate for the converting copy constructor from a compatible outcome to be available. - template - static constexpr bool enable_compatible_conversion = // - (std::is_void::value || - detail::is_explicitly_constructible::value_type>) // if our value types are constructible - &&(std::is_void::value || - detail::is_explicitly_constructible::error_type>) // if our error types are constructible - &&(std::is_void::value || - detail::is_explicitly_constructible::exception_type>) // if our exception types are constructible - ; - - // Predicate for the converting constructor from a make_error_code() of the input to be available. - template - static constexpr bool enable_make_error_code_compatible_conversion = // - trait::is_error_code_available>::value // if error type has an error code - && !enable_compatible_conversion // and the normal compatible conversion is not available - && (std::is_void::value || - detail::is_explicitly_constructible::value_type>) // and if our value types are constructible - &&detail::is_explicitly_constructible::type> // and our error type is constructible from a make_error_code() - && (std::is_void::value || - detail::is_explicitly_constructible::exception_type>); // and our exception types are constructible - - // Predicate for the implicit converting inplace constructor from a compatible input to be available. - struct disable_inplace_value_error_exception_constructor; - template - using choose_inplace_value_error_exception_constructor = std::conditional_t< // - ((static_cast(detail::is_constructible) + static_cast(detail::is_constructible) + - static_cast(detail::is_constructible)) > 1), // - disable_inplace_value_error_exception_constructor, // - std::conditional_t< // - detail::is_constructible, // - value_type, // - std::conditional_t< // - detail::is_constructible, // - error_type, // - std::conditional_t< // - detail::is_constructible, // - exception_type, // - disable_inplace_value_error_exception_constructor>>>>; - template - static constexpr bool enable_inplace_value_error_exception_constructor = // - implicit_constructors_enabled && - !std::is_same, disable_inplace_value_error_exception_constructor>::value; - }; - - // Select whether to use basic_outcome_failure_observers or not - template - using select_basic_outcome_failure_observers = // - std::conditional_t::value && trait::is_exception_ptr_available

::value, - basic_outcome_failure_observers, Base>; - - template constexpr inline const V &extract_exception_from_failure(const failure_type &v) { return v.exception(); } - template constexpr inline V &&extract_exception_from_failure(failure_type &&v) - { - return static_cast &&>(v).exception(); - } - template constexpr inline const U &extract_exception_from_failure(const failure_type &v) { return v.error(); } - template constexpr inline U &&extract_exception_from_failure(failure_type &&v) - { - return static_cast &&>(v).error(); - } - - template struct is_basic_outcome - { - static constexpr bool value = false; - }; - template struct is_basic_outcome> - { - static constexpr bool value = true; - }; -} // namespace detail - -/*! AWAITING HUGO JSON CONVERSION TOOL -type alias template is_basic_outcome. Potential doc page: `is_basic_outcome` -*/ -template using is_basic_outcome = detail::is_basic_outcome>; -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template static constexpr bool is_basic_outcome_v = detail::is_basic_outcome>::value; - -namespace concepts -{ -#if defined(__cpp_concepts) - /* The `basic_outcome` concept. - \requires That `U` matches a `basic_outcome`. - */ - template - concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL basic_outcome = - BOOST_OUTCOME_V2_NAMESPACE::is_basic_outcome::value || - (requires(U v) { - BOOST_OUTCOME_V2_NAMESPACE::basic_outcome(v); - } && // - detail::convertible< - U, BOOST_OUTCOME_V2_NAMESPACE::basic_outcome> && // - detail::base_of< - BOOST_OUTCOME_V2_NAMESPACE::basic_outcome, U>); -#else - namespace detail - { - inline no_match match_basic_outcome(...); - template >::value && // - std::is_base_of, T>::value, - bool> = true> - inline BOOST_OUTCOME_V2_NAMESPACE::basic_outcome match_basic_outcome(BOOST_OUTCOME_V2_NAMESPACE::basic_outcome &&, T &&); - - template - static constexpr bool basic_outcome = - BOOST_OUTCOME_V2_NAMESPACE::is_basic_outcome::value || - !std::is_same>(), - std::declval>()))>::value; - } // namespace detail - /* The `basic_outcome` concept. - \requires That `U` matches a `basic_outcome`. - */ - template static constexpr bool basic_outcome = detail::basic_outcome; -#endif -} // namespace concepts - -namespace hooks -{ - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template constexpr inline void hook_outcome_construction(T * /*unused*/, U &&... /*unused*/) noexcept {} - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template constexpr inline void hook_outcome_copy_construction(T * /*unused*/, U && /*unused*/) noexcept {} - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template constexpr inline void hook_outcome_move_construction(T * /*unused*/, U && /*unused*/) noexcept {} - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template - constexpr inline void hook_outcome_in_place_construction(T * /*unused*/, in_place_type_t /*unused*/, Args &&... /*unused*/) noexcept - { - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template - constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept; -} // namespace hooks - -/*! AWAITING HUGO JSON CONVERSION TOOL -type definition template basic_outcome. Potential doc page: `basic_outcome` -*/ -template // -class BOOST_OUTCOME_NODISCARD basic_outcome -#if defined(BOOST_OUTCOME_DOXYGEN_IS_IN_THE_HOUSE) || defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) - : public detail::basic_outcome_failure_observers, R, S, P, NoValuePolicy>, - public detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, - public detail::basic_result_final -#else - : public detail::select_basic_outcome_failure_observers< - detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy> -#endif -{ - static_assert(trait::type_can_be_used_in_basic_result

, "The exception_type cannot be used"); - static_assert(std::is_void

::value || std::is_default_constructible

::value, "exception_type must be void or default constructible"); - using base = detail::select_basic_outcome_failure_observers< - detail::basic_outcome_exception_observers, R, S, P, NoValuePolicy>, R, S, P, NoValuePolicy>; - friend struct policy::base; - template // - friend class basic_outcome; - template - friend constexpr inline void hooks::override_outcome_exception(basic_outcome *o, X &&v) noexcept; // NOLINT - - struct implicit_constructors_disabled_tag - { - }; - struct value_converting_constructor_tag - { - }; - struct error_converting_constructor_tag - { - }; - struct error_condition_converting_constructor_tag - { - }; - struct exception_converting_constructor_tag - { - }; - struct error_exception_converting_constructor_tag - { - }; - struct explicit_valueorerror_converting_constructor_tag - { - }; - struct explicit_compatible_copy_conversion_tag - { - }; - struct explicit_compatible_move_conversion_tag - { - }; - struct explicit_make_error_code_compatible_copy_conversion_tag - { - }; - struct explicit_make_error_code_compatible_move_conversion_tag - { - }; - struct error_failure_tag - { - }; - struct exception_failure_tag - { - }; - - struct disable_in_place_value_type - { - }; - struct disable_in_place_error_type - { - }; - struct disable_in_place_exception_type - { - }; - -public: - using value_type = R; - using error_type = S; - using exception_type = P; - using no_value_policy_type = NoValuePolicy; - - template using rebind = basic_outcome; - -protected: - // Requirement predicates for outcome. - struct predicate - { - using base = detail::outcome_predicates; - - // Predicate for any constructors to be available at all - static constexpr bool constructors_enabled = - (!std::is_same, std::decay_t>::value || (std::is_void::value && std::is_void::value)) // - && (!std::is_same, std::decay_t>::value || - (std::is_void::value && std::is_void::value)) // - && (!std::is_same, std::decay_t>::value || - (std::is_void::value && std::is_void::value)) // - ; - - // Predicate for implicit constructors to be available at all - static constexpr bool implicit_constructors_enabled = constructors_enabled && base::implicit_constructors_enabled; - - // Predicate for the value converting constructor to be available. - template - static constexpr bool enable_value_converting_constructor = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_value_converting_constructor; - - // Predicate for the error converting constructor to be available. - template - static constexpr bool enable_error_converting_constructor = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_error_converting_constructor; - - // Predicate for the error condition converting constructor to be available. - template - static constexpr bool enable_error_condition_converting_constructor = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_error_condition_converting_constructor; - - // Predicate for the exception converting constructor to be available. - template - static constexpr bool enable_exception_converting_constructor = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_exception_converting_constructor; - - // Predicate for the error + exception converting constructor to be available. - template - static constexpr bool enable_error_exception_converting_constructor = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_error_exception_converting_constructor; - - // Predicate for the converting constructor from a compatible input to be available. - template - static constexpr bool enable_compatible_conversion = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_compatible_conversion; - - // Predicate for the converting constructor from a make_error_code() of the input to be available. - template - static constexpr bool enable_make_error_code_compatible_conversion = // - constructors_enabled // - && !std::is_same, basic_outcome>::value // not my type - && base::template enable_make_error_code_compatible_conversion; - - // Predicate for the inplace construction of value to be available. - template - static constexpr bool enable_inplace_value_constructor = // - constructors_enabled // - && (std::is_void::value // - || detail::is_constructible); - - // Predicate for the inplace construction of error to be available. - template - static constexpr bool enable_inplace_error_constructor = // - constructors_enabled // - && (std::is_void::value // - || detail::is_constructible); - - // Predicate for the inplace construction of exception to be available. - template - static constexpr bool enable_inplace_exception_constructor = // - constructors_enabled // - && (std::is_void::value // - || detail::is_constructible); - - // Predicate for the implicit converting inplace constructor to be available. - template - static constexpr bool enable_inplace_value_error_exception_constructor = // - constructors_enabled // - &&base::template enable_inplace_value_error_exception_constructor; - template - using choose_inplace_value_error_exception_constructor = typename base::template choose_inplace_value_error_exception_constructor; - }; - -public: - using value_type_if_enabled = - std::conditional_t::value || std::is_same::value, disable_in_place_value_type, value_type>; - using error_type_if_enabled = - std::conditional_t::value || std::is_same::value, disable_in_place_error_type, error_type>; - using exception_type_if_enabled = std::conditional_t::value || std::is_same::value, - disable_in_place_exception_type, exception_type>; - -protected: - detail::devoid _ptr; - -public: - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class Arg, class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED((!predicate::constructors_enabled && sizeof...(Args) >= 0))) - basic_outcome(Arg && /*unused*/, Args &&... /*unused*/) = delete; // NOLINT basic_outcome<> with any of the same type is NOT SUPPORTED, see docs! - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED((predicate::constructors_enabled && !predicate::implicit_constructors_enabled // - && (detail::is_implicitly_constructible || detail::is_implicitly_constructible || - detail::is_implicitly_constructible) ))) - basic_outcome(T && /*unused*/, implicit_constructors_disabled_tag /*unused*/ = implicit_constructors_disabled_tag()) = - delete; // NOLINT Implicit constructors disabled, use explicit in_place_type, success() or failure(). see docs! - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_value_converting_constructor)) - constexpr basic_outcome(T &&t, value_converting_constructor_tag /*unused*/ = value_converting_constructor_tag()) noexcept( - detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, static_cast(t)} - , _ptr() - { - using namespace hooks; - hook_outcome_construction(this, static_cast(t)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_converting_constructor)) - constexpr basic_outcome(T &&t, error_converting_constructor_tag /*unused*/ = error_converting_constructor_tag()) noexcept( - detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, static_cast(t)} - , _ptr() - { - using namespace hooks; - hook_outcome_construction(this, static_cast(t)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class ErrorCondEnum) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(error_type(make_error_code(ErrorCondEnum()))), // - BOOST_OUTCOME_TPRED(predicate::template enable_error_condition_converting_constructor)) - constexpr basic_outcome(ErrorCondEnum &&t, error_condition_converting_constructor_tag /*unused*/ = error_condition_converting_constructor_tag()) noexcept( - noexcept(error_type(make_error_code(static_cast(t))))) // NOLINT - : base{in_place_type, make_error_code(t)} - { - using namespace hooks; - hook_outcome_construction(this, static_cast(t)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_exception_converting_constructor)) - constexpr basic_outcome(T &&t, exception_converting_constructor_tag /*unused*/ = exception_converting_constructor_tag()) noexcept( - detail::is_nothrow_constructible) // NOLINT - : base() - , _ptr(static_cast(t)) - { - using namespace hooks; - this->_state._status.set_have_exception(true); - hook_outcome_construction(this, static_cast(t)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_error_exception_converting_constructor)) - constexpr basic_outcome(T &&a, U &&b, error_exception_converting_constructor_tag /*unused*/ = error_exception_converting_constructor_tag()) noexcept( - detail::is_nothrow_constructible &&detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, static_cast(a)} - , _ptr(static_cast(b)) - { - using namespace hooks; - this->_state._status.set_have_exception(true); - hook_outcome_construction(this, static_cast(a), static_cast(b)); - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(convert::value_or_error>::enable_result_inputs || !concepts::basic_result), // - BOOST_OUTCOME_TPRED(convert::value_or_error>::enable_outcome_inputs || !concepts::basic_outcome), // - BOOST_OUTCOME_TEXPR(convert::value_or_error>{}(std::declval()))) - constexpr explicit basic_outcome(T &&o, - explicit_valueorerror_converting_constructor_tag /*unused*/ = explicit_valueorerror_converting_constructor_tag()) // NOLINT - : basic_outcome{convert::value_or_error>{}(static_cast(o))} - { - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion)) - constexpr explicit basic_outcome( - const basic_outcome &o, - explicit_compatible_copy_conversion_tag /*unused*/ = - explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible &&detail::is_nothrow_constructible - &&detail::is_nothrow_constructible) - : base{typename base::compatible_conversion_tag(), o} - , _ptr(o._ptr) - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_compatible_conversion)) - constexpr explicit basic_outcome( - basic_outcome &&o, - explicit_compatible_move_conversion_tag /*unused*/ = - explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible &&detail::is_nothrow_constructible - &&detail::is_nothrow_constructible) - : base{typename base::compatible_conversion_tag(), static_cast &&>(o)} - , _ptr(static_cast::exception_type &&>(o._ptr)) - { - using namespace hooks; - hook_outcome_move_construction(this, static_cast &&>(o)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_compatible_conversion)) - constexpr explicit basic_outcome( - const basic_result &o, - explicit_compatible_copy_conversion_tag /*unused*/ = - explicit_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible &&detail::is_nothrow_constructible - &&detail::is_nothrow_constructible) - : base{typename base::compatible_conversion_tag(), o} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_compatible_conversion)) - constexpr explicit basic_outcome( - basic_result &&o, - explicit_compatible_move_conversion_tag /*unused*/ = - explicit_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible &&detail::is_nothrow_constructible - &&detail::is_nothrow_constructible) - : base{typename base::compatible_conversion_tag(), static_cast &&>(o)} - , _ptr() - { - using namespace hooks; - hook_outcome_move_construction(this, static_cast &&>(o)); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_make_error_code_compatible_conversion)) - constexpr explicit basic_outcome(const basic_result &o, - explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = - explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(detail::is_nothrow_constructible - &&noexcept(make_error_code(std::declval())) && - detail::is_nothrow_constructible) - : base{typename base::make_error_code_compatible_conversion_tag(), o} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(detail::result_predicates::template enable_make_error_code_compatible_conversion)) - constexpr explicit basic_outcome(basic_result &&o, - explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = - explicit_make_error_code_compatible_move_conversion_tag()) noexcept(detail::is_nothrow_constructible - &&noexcept(make_error_code(std::declval())) && - detail::is_nothrow_constructible) - : base{typename base::make_error_code_compatible_conversion_tag(), static_cast &&>(o)} - , _ptr() - { - using namespace hooks; - hook_outcome_move_construction(this, static_cast &&>(o)); - } - - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor)) - constexpr explicit basic_outcome(in_place_type_t _, Args &&... args) noexcept(detail::is_nothrow_constructible) - : base{_, static_cast(args)...} - , _ptr() - { - using namespace hooks; - hook_outcome_in_place_construction(this, in_place_type, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class U, class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, - Args &&... args) noexcept(detail::is_nothrow_constructible, Args...>) - : base{_, il, static_cast(args)...} - , _ptr() - { - using namespace hooks; - hook_outcome_in_place_construction(this, in_place_type, il, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor)) - constexpr explicit basic_outcome(in_place_type_t _, Args &&... args) noexcept(detail::is_nothrow_constructible) - : base{_, static_cast(args)...} - , _ptr() - { - using namespace hooks; - hook_outcome_in_place_construction(this, in_place_type, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class U, class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_error_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t _, std::initializer_list il, - Args &&... args) noexcept(detail::is_nothrow_constructible, Args...>) - : base{_, il, static_cast(args)...} - , _ptr() - { - using namespace hooks; - hook_outcome_in_place_construction(this, in_place_type, il, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor)) - constexpr explicit basic_outcome(in_place_type_t /*unused*/, - Args &&... args) noexcept(detail::is_nothrow_constructible) - : base() - , _ptr(static_cast(args)...) - { - using namespace hooks; - this->_state._status.set_have_exception(true); - hook_outcome_in_place_construction(this, in_place_type, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class U, class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_exception_constructor, Args...>)) - constexpr explicit basic_outcome(in_place_type_t /*unused*/, std::initializer_list il, - Args &&... args) noexcept(detail::is_nothrow_constructible, Args...>) - : base() - , _ptr(il, static_cast(args)...) - { - using namespace hooks; - this->_state._status.set_have_exception(true); - hook_outcome_in_place_construction(this, in_place_type, il, static_cast(args)...); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class A1, class A2, class... Args) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(predicate::template enable_inplace_value_error_exception_constructor)) - constexpr basic_outcome(A1 &&a1, A2 &&a2, Args &&... args) noexcept( - noexcept(typename predicate::template choose_inplace_value_error_exception_constructor(std::declval(), std::declval(), - std::declval()...))) - : basic_outcome(in_place_type>, static_cast(a1), - static_cast(a2), static_cast(args)...) - { - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - constexpr basic_outcome(const success_type &o) noexcept(std::is_nothrow_default_constructible::value) // NOLINT - : base{in_place_type} - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const success_type &o) noexcept(detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_value_from_success(o)} - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(success_type &&o) noexcept(detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_value_from_success(static_cast &&>(o))} - { - using namespace hooks; - hook_outcome_move_construction(this, static_cast &&>(o)); - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, - error_failure_tag /*unused*/ = error_failure_tag()) noexcept(detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_error_from_failure(o)} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, - exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(detail::is_nothrow_constructible) // NOLINT - : base() - , _ptr(detail::extract_exception_from_failure(o)) - { - this->_state._status.set_have_exception(true); - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_make_error_code_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, - explicit_make_error_code_compatible_copy_conversion_tag /*unused*/ = - explicit_make_error_code_compatible_copy_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT - : base{in_place_type, make_error_code(detail::extract_error_from_failure(o))} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(const failure_type &o, explicit_compatible_copy_conversion_tag /*unused*/ = explicit_compatible_copy_conversion_tag()) noexcept( - detail::is_nothrow_constructible &&detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_error_from_failure(o)} - , _ptr(detail::extract_exception_from_failure(o)) - { - if(!o.has_error()) - { - this->_state._status.set_have_error(false); - } - if(o.has_exception()) - { - this->_state._status.set_have_exception(true); - } - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, - error_failure_tag /*unused*/ = error_failure_tag()) noexcept(detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_error_from_failure(static_cast &&>(o))} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, - exception_failure_tag /*unused*/ = exception_failure_tag()) noexcept(detail::is_nothrow_constructible) // NOLINT - : base() - , _ptr(detail::extract_exception_from_failure(static_cast &&>(o))) - { - this->_state._status.set_have_exception(true); - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_make_error_code_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, - explicit_make_error_code_compatible_move_conversion_tag /*unused*/ = - explicit_make_error_code_compatible_move_conversion_tag()) noexcept(noexcept(make_error_code(std::declval()))) // NOLINT - : base{in_place_type, make_error_code(detail::extract_error_from_failure(static_cast &&>(o)))} - , _ptr() - { - using namespace hooks; - hook_outcome_copy_construction(this, o); - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(!std::is_void::value && predicate::template enable_compatible_conversion)) - constexpr basic_outcome(failure_type &&o, explicit_compatible_move_conversion_tag /*unused*/ = explicit_compatible_move_conversion_tag()) noexcept( - detail::is_nothrow_constructible &&detail::is_nothrow_constructible) // NOLINT - : base{in_place_type, detail::extract_error_from_failure(static_cast &&>(o))} - , _ptr(detail::extract_exception_from_failure(static_cast &&>(o))) - { - if(!o.has_error()) - { - this->_state._status.set_have_error(false); - } - if(o.has_exception()) - { - this->_state._status.set_have_exception(true); - } - using namespace hooks; - hook_outcome_move_construction(this, static_cast &&>(o)); - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - using base::operator==; - using base::operator!=; - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>())) - constexpr bool operator==(const basic_outcome &o) const noexcept( // - noexcept(std::declval>() == std::declval>()) // - && noexcept(std::declval>() == std::declval>()) // - && noexcept(std::declval>() == std::declval>())) - { - if(this->_state._status.have_value() && o._state._status.have_value()) - { - return this->_state._value == o._state._value; // NOLINT - } - if(this->_state._status.have_error() && o._state._status.have_error() // - && this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_error == o._error && this->_ptr == o._ptr; - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error == o._error; - } - if(this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_ptr == o._ptr; - } - return false; - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() == std::declval()), // - BOOST_OUTCOME_TEXPR(std::declval() == std::declval())) - constexpr bool operator==(const failure_type &o) const noexcept( // - noexcept(std::declval() == std::declval()) && noexcept(std::declval() == std::declval())) - { - if(this->_state._status.have_error() && o._state._status.have_error() // - && this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_error == o.error() && this->_ptr == o.exception(); - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error == o.error(); - } - if(this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_ptr == o.exception(); - } - return false; - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U, class V, class W) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>())) - constexpr bool operator!=(const basic_outcome &o) const noexcept( // - noexcept(std::declval>() != std::declval>()) // - && noexcept(std::declval>() != std::declval>()) // - && noexcept(std::declval>() != std::declval>())) - { - if(this->_state._status.have_value() && o._state._status.have_value()) - { - return this->_state._value != o._state._value; // NOLINT - } - if(this->_state._status.have_error() && o._state._status.have_error() // - && this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_error != o._error || this->_ptr != o._ptr; - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error != o._error; - } - if(this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_ptr != o._ptr; - } - return true; - } - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() != std::declval()), // - BOOST_OUTCOME_TEXPR(std::declval() != std::declval())) - constexpr bool operator!=(const failure_type &o) const noexcept( // - noexcept(std::declval() == std::declval()) && noexcept(std::declval() == std::declval())) - { - if(this->_state._status.have_error() && o._state._status.have_error() // - && this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_error != o.error() || this->_ptr != o.exception(); - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error != o.error(); - } - if(this->_state._status.have_exception() && o._state._status.have_exception()) - { - return this->_ptr != o.exception(); - } - return true; - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - constexpr void swap(basic_outcome &o) noexcept((std::is_void::value || detail::is_nothrow_swappable::value) // - && (std::is_void::value || detail::is_nothrow_swappable::value) // - && (std::is_void::value || detail::is_nothrow_swappable::value)) - { -#ifndef BOOST_NO_EXCEPTIONS - constexpr bool value_throws = !std::is_void::value && !detail::is_nothrow_swappable::value; - constexpr bool error_throws = !std::is_void::value && !detail::is_nothrow_swappable::value; - constexpr bool exception_throws = !std::is_void::value && !detail::is_nothrow_swappable::value; -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant -#endif - if(!exception_throws && !value_throws && !error_throws) - { - // Simples - detail::basic_result_storage_swap(*this, o); - using std::swap; - swap(this->_ptr, o._ptr); - return; - } - struct _ - { - basic_outcome &a, &b; - bool exceptioned{false}; - bool all_good{false}; - ~_() - { - if(!all_good) - { - // We lost one of the values - a._state._status.set_have_lost_consistency(true); - b._state._status.set_have_lost_consistency(true); - return; - } - if(exceptioned) - { - // The value + error swap threw an exception. Try to swap back _ptr - try - { - strong_swap(all_good, a._ptr, b._ptr); - } - catch(...) - { - // We lost one of the values - a._state._status.set_have_lost_consistency(true); - b._state._status.set_have_lost_consistency(true); - // throw away second exception - } - - // Prevent has_value() == has_error() or has_value() == has_exception() - auto check = [](basic_outcome *t) { - if(t->has_value() && (t->has_error() || t->has_exception())) - { - t->_state._status.set_have_error(false).set_have_exception(false); - t->_state._status.set_have_lost_consistency(true); - } - if(!t->has_value() && !(t->has_error() || t->has_exception())) - { - // Choose error, for no particular reason - t->_state._status.set_have_error(true).set_have_lost_consistency(true); - } - }; - check(&a); - check(&b); - } - } - } _{*this, o}; - strong_swap(_.all_good, this->_ptr, o._ptr); - _.exceptioned = true; - detail::basic_result_storage_swap(*this, o); - _.exceptioned = false; -#ifdef _MSC_VER -#pragma warning(pop) -#endif -#else - detail::basic_result_storage_swap(*this, o); - using std::swap; - swap(this->_ptr, o._ptr); -#endif - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - failure_type as_failure() const & - { - if(this->has_error() && this->has_exception()) - { - return failure_type(this->assume_error(), this->assume_exception()); - } - if(this->has_exception()) - { - return failure_type(in_place_type, this->assume_exception()); - } - return failure_type(in_place_type, this->assume_error()); - } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - failure_type as_failure() && - { - if(this->has_error() && this->has_exception()) - { - return failure_type(static_cast(this->assume_error()), static_cast

(this->assume_exception())); - } - if(this->has_exception()) - { - return failure_type(in_place_type, static_cast

(this->assume_exception())); - } - return failure_type(in_place_type, static_cast(this->assume_error())); - } - -#ifdef __APPLE__ - failure_type _xcode_workaround_as_failure() &&; -#endif -}; - -// C++ 20 operator== rewriting should take care of this for us, indeed -// if we don't disable it, we cause Concept recursion to infinity! -#if __cplusplus < 202000L -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -BOOST_OUTCOME_TEMPLATE(class T, class U, class V, // - class R, class S, class P, class N) -BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>())) -constexpr inline bool operator==(const basic_result &a, const basic_outcome &b) noexcept( // -noexcept(std::declval>() == std::declval>())) -{ - return b == a; -} -#endif -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -BOOST_OUTCOME_TEMPLATE(class T, class U, class V, // - class R, class S, class P, class N) -BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>())) -constexpr inline bool operator!=(const basic_result &a, const basic_outcome &b) noexcept( // -noexcept(std::declval>() != std::declval>())) -{ - return b != a; -} -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template inline void swap(basic_outcome &a, basic_outcome &b) noexcept(noexcept(a.swap(b))) -{ - a.swap(b); -} - -namespace hooks -{ - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template - constexpr inline void override_outcome_exception(basic_outcome *o, U &&v) noexcept - { - o->_ptr = static_cast(v); // NOLINT - o->_state._status.set_have_exception(true); - } -} // namespace hooks - -BOOST_OUTCOME_V2_NAMESPACE_END - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#include "detail/basic_outcome_exception_observers_impl.hpp" - -#if !defined(NDEBUG) -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -// Check is trivial in all ways except default constructibility and standard layout -// static_assert(std::is_trivial>::value, "outcome is not trivial!"); -// static_assert(std::is_trivially_default_constructible>::value, "outcome is not trivially default -// constructible!"); -static_assert(std::is_trivially_copyable>::value, "outcome is not trivially copyable!"); -static_assert(std::is_trivially_assignable, basic_outcome>::value, - "outcome is not trivially assignable!"); -static_assert(std::is_trivially_destructible>::value, "outcome is not trivially destructible!"); -static_assert(std::is_trivially_copy_constructible>::value, - "outcome is not trivially copy constructible!"); -static_assert(std::is_trivially_move_constructible>::value, - "outcome is not trivially move constructible!"); -static_assert(std::is_trivially_copy_assignable>::value, "outcome is not trivially copy assignable!"); -static_assert(std::is_trivially_move_assignable>::value, "outcome is not trivially move assignable!"); -// Can't be standard layout as non-static member data is defined in more than one inherited class -// static_assert(std::is_standard_layout>::value, "outcome is not a standard layout type!"); -BOOST_OUTCOME_V2_NAMESPACE_END -#endif - -#endif diff --git a/boost/outcome/boost_result.hpp b/boost/outcome/boost_result.hpp deleted file mode 100755 index 27d02ef30e19b2d9581475f8b27489a4d1e6c733..0000000000000000000000000000000000000000 --- a/boost/outcome/boost_result.hpp +++ /dev/null @@ -1,191 +0,0 @@ -/* A very simple result type -(C) 2017-2020 Niall Douglas (10 commits) -File Created: June 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BOOST_RESULT_HPP -#define BOOST_OUTCOME_BOOST_RESULT_HPP - -#include "config.hpp" - -#include "boost/system/system_error.hpp" -#include "boost/version.hpp" - -#if BOOST_VERSION < 107500 || !defined(BOOST_NO_EXCEPTIONS) -#include "boost/exception_ptr.hpp" -#else -namespace boost -{ - class exception_ptr; -} -#endif - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -namespace policy -{ - namespace detail - { - /* Pass through `make_error_code` function for `boost::system::error_code`. - */ - inline boost::system::error_code make_error_code(boost::system::error_code v) { return v; } - -#if BOOST_VERSION < 107500 - /* Pass through `make_exception_ptr` function for `boost::exception_ptr`. - The reason this needs to be here, declared before the rest of Outcome, - is that there is no boost::make_exception_ptr as Boost still uses the old - naming boost::copy_exception. Therefore the ADL discovered make_exception_ptr - doesn't work, hence this hacky pre-declaration here. - - I was tempted to just inject a boost::make_exception_ptr, but I can see - Boost doing that itself at some point. This hack should keep working after. - */ - inline boost::exception_ptr make_exception_ptr(boost::exception_ptr v) { return v; } -#endif - } // namespace detail -} // namespace policy -BOOST_OUTCOME_V2_NAMESPACE_END - -#include "std_result.hpp" - - -// ADL injection of outcome_throw_as_system_error_with_payload -namespace boost -{ - namespace system - { - inline void outcome_throw_as_system_error_with_payload(const error_code &error) { BOOST_OUTCOME_THROW_EXCEPTION(system_error(error)); } - namespace errc - { - BOOST_OUTCOME_TEMPLATE(class Error) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(is_error_code_enum>::value || is_error_condition_enum>::value)) - inline void outcome_throw_as_system_error_with_payload(Error &&error) { BOOST_OUTCOME_THROW_EXCEPTION(system_error(make_error_code(error))); } - } // namespace errc - } // namespace system -} // namespace boost - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace detail -{ - // Customise _set_error_is_errno - template constexpr inline void _set_error_is_errno(State &state, const boost::system::error_code &error) - { - if(error.category() == boost::system::generic_category() -#ifndef _WIN32 - || error.category() == boost::system::system_category() -#endif - ) - { - state._status.set_have_error_is_errno(true); - } - } - template constexpr inline void _set_error_is_errno(State &state, const boost::system::error_condition &error) - { - if(error.category() == boost::system::generic_category() -#ifndef _WIN32 - || error.category() == boost::system::system_category() -#endif - ) - { - state._status.set_have_error_is_errno(true); - } - } - template constexpr inline void _set_error_is_errno(State &state, const boost::system::errc::errc_t & /*unused*/) - { - state._status.set_have_error_is_errno(true); - } - -} // namespace detail - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -namespace trait -{ - namespace detail - { - // Shortcut these for lower build impact - template <> struct _is_error_code_available - { - static constexpr bool value = true; - using type = boost::system::error_code; - }; - template <> struct _is_exception_ptr_available - { - static constexpr bool value = true; - using type = boost::exception_ptr; - }; - } // namespace detail - - // boost::system::error_code is an error type - template <> struct is_error_type - { - static constexpr bool value = true; - }; - // boost::system::error_code::errc_t is an error type - template <> struct is_error_type - { - static constexpr bool value = true; - }; - // boost::exception_ptr is an error types - template <> struct is_error_type - { - static constexpr bool value = true; - }; - // For boost::system::error_code, boost::system::is_error_condition_enum<> is the trait we want. - template struct is_error_type_enum - { - static constexpr bool value = boost::system::is_error_condition_enum::value; - }; - -} // namespace trait - - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template > // -using boost_result = basic_result; - -/*! AWAITING HUGO JSON CONVERSION TOOL -type alias template boost_unchecked. Potential doc page: `boost_unchecked` -*/ -template using boost_unchecked = boost_result; - -/*! AWAITING HUGO JSON CONVERSION TOOL -type alias template boost_checked. Potential doc page: `boost_checked` -*/ -template using boost_checked = boost_result>; - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/config.hpp b/boost/outcome/config.hpp deleted file mode 100755 index 7423c8184eec6607f4475ee16c8ce4ab59578be3..0000000000000000000000000000000000000000 --- a/boost/outcome/config.hpp +++ /dev/null @@ -1,359 +0,0 @@ -/* Configure Boost.Outcome with Boost -(C) 2015-2020 Niall Douglas (7 commits) -File Created: August 2015 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_V2_CONFIG_HPP -#define BOOST_OUTCOME_V2_CONFIG_HPP - -#include "detail/version.hpp" - -// Pull in detection of __MINGW64_VERSION_MAJOR -#if defined(__MINGW32__) && !defined(DOXYGEN_IS_IN_THE_HOUSE) -#include <_mingw.h> -#endif - -#include - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -#error Boost.Outcome needs variadic template support in the compiler -#endif -#if defined(BOOST_NO_CXX14_CONSTEXPR) && _MSC_FULL_VER < 191100000 -#error Boost.Outcome needs constexpr (C++ 14) support in the compiler -#endif -#ifdef BOOST_NO_CXX14_VARIABLE_TEMPLATES -#error Boost.Outcome needs variable template support in the compiler -#endif -#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 6 -#error Due to a bug in nested template variables parsing, Boost.Outcome does not work on GCCs earlier than v6. -#endif - -#ifndef BOOST_OUTCOME_SYMBOL_VISIBLE -#define BOOST_OUTCOME_SYMBOL_VISIBLE BOOST_SYMBOL_VISIBLE -#endif -#ifdef __has_cpp_attribute -#define BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr) -#else -#define BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(attr) (0) -#endif -// Weird that Boost.Config doesn't define a BOOST_NO_CXX17_NODISCARD -#ifndef BOOST_OUTCOME_NODISCARD -#if BOOST_OUTCOME_HAS_CPP_ATTRIBUTE(nodiscard) -#define BOOST_OUTCOME_NODISCARD [[nodiscard]] -#elif defined(__clang__) // deliberately not GCC -#define BOOST_OUTCOME_NODISCARD __attribute__((warn_unused_result)) -#elif defined(_MSC_VER) -// _Must_inspect_result_ expands into this -#define BOOST_OUTCOME_NODISCARD \ - __declspec("SAL_name" \ - "(" \ - "\"_Must_inspect_result_\"" \ - "," \ - "\"\"" \ - "," \ - "\"2\"" \ - ")") __declspec("SAL_begin") __declspec("SAL_post") __declspec("SAL_mustInspect") __declspec("SAL_post") __declspec("SAL_checkReturn") __declspec("SAL_end") -#endif -#endif -#ifndef BOOST_OUTCOME_NODISCARD -#define BOOST_OUTCOME_NODISCARD -#endif -#ifndef BOOST_OUTCOME_THREAD_LOCAL -#ifndef BOOST_NO_CXX11_THREAD_LOCAL -#define BOOST_OUTCOME_THREAD_LOCAL thread_local -#else -#if defined(_MSC_VER) -#define BOOST_OUTCOME_THREAD_LOCAL __declspec(thread) -#elif defined(__GNUC__) -#define BOOST_OUTCOME_THREAD_LOCAL __thread -#else -#error Unknown compiler, cannot set BOOST_OUTCOME_THREAD_LOCAL -#endif -#endif -#endif -// Can't use the QuickCppLib preprocessor metaprogrammed Concepts TS support, so ... -#ifndef BOOST_OUTCOME_TEMPLATE -#define BOOST_OUTCOME_TEMPLATE(...) template <__VA_ARGS__ -#endif -#ifndef BOOST_OUTCOME_TREQUIRES -#define BOOST_OUTCOME_TREQUIRES(...) , __VA_ARGS__ > -#endif -#ifndef BOOST_OUTCOME_TEXPR -#define BOOST_OUTCOME_TEXPR(...) typename = decltype(__VA_ARGS__) -#endif -#ifndef BOOST_OUTCOME_TPRED -#define BOOST_OUTCOME_TPRED(...) typename = std::enable_if_t<__VA_ARGS__> -#endif -#ifndef BOOST_OUTCOME_REQUIRES -#if defined(__cpp_concepts) && (!defined(_MSC_VER) || _MSC_FULL_VER >= 192400000) // VS 2019 16.3 is broken here -#define BOOST_OUTCOME_REQUIRES(...) requires(__VA_ARGS__) -#else -#define BOOST_OUTCOME_REQUIRES(...) -#endif -#endif - -#ifndef BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR -#define BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR 210 // the v2.1 Outcome release -#endif - -namespace boost -{ -#define BOOST_OUTCOME_V2 - //! The Boost.Outcome namespace - namespace outcome_v2 - { - } -} -/*! The namespace of this Boost.Outcome v2. -*/ -#define BOOST_OUTCOME_V2_NAMESPACE boost::outcome_v2 -/*! Expands into the appropriate namespace markup to enter the Boost.Outcome v2 namespace. -*/ -#define BOOST_OUTCOME_V2_NAMESPACE_BEGIN \ - namespace boost \ - { \ - namespace outcome_v2 \ - { -/*! Expands into the appropriate namespace markup to enter the C++ module -exported Boost.Outcome v2 namespace. -*/ -#define BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN \ - namespace boost \ - { \ - namespace outcome_v2 \ - { -/*! \brief Expands into the appropriate namespace markup to exit the Boost.Outcome v2 namespace. -\ingroup config -*/ -#define BOOST_OUTCOME_V2_NAMESPACE_END \ - } \ - } - -#include // for uint32_t etc -#include -#include // for future serialisation -#include // for placement in moves etc -#include - -#ifndef BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE -#if defined(_MSC_VER) && _HAS_CXX17 -#define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 1 // MSVC always has std::in_place_type -#elif __cplusplus >= 201700 -// libstdc++ before GCC 6 doesn't have it, despite claiming C++ 17 support -#ifdef __has_include -#if !__has_include() -#define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 0 // must have it if is present -#endif -#endif - -#ifndef BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE -#define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 1 -#endif -#else -#define BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE 0 -#endif -#endif - -#if BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE -#include // for in_place_type_t - -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -template using in_place_type_t = std::in_place_type_t; -using std::in_place_type; -BOOST_OUTCOME_V2_NAMESPACE_END -#else -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -//! Aliases `std::in_place_type_t` if on C++ 17 or later, else defined locally. -template struct in_place_type_t -{ - explicit in_place_type_t() = default; -}; -//! Aliases `std::in_place_type` if on C++ 17 or later, else defined locally. -template constexpr in_place_type_t in_place_type{}; -BOOST_OUTCOME_V2_NAMESPACE_END -#endif - -#ifndef BOOST_OUTCOME_TRIVIAL_ABI -#if defined(STANDARDESE_IS_IN_THE_HOUSE) || __clang_major__ >= 7 -//! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. -#define BOOST_OUTCOME_TRIVIAL_ABI [[clang::trivial_abi]] -#else -#define BOOST_OUTCOME_TRIVIAL_ABI -#endif -#endif - -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -namespace detail -{ - // Test if type is an in_place_type_t - template struct is_in_place_type_t - { - static constexpr bool value = false; - }; - template struct is_in_place_type_t> - { - static constexpr bool value = true; - }; - - // Replace void with constructible void_type - struct empty_type - { - }; - struct void_type - { - // We always compare true to another instance of me - constexpr bool operator==(void_type /*unused*/) const noexcept { return true; } - constexpr bool operator!=(void_type /*unused*/) const noexcept { return false; } - }; - template using devoid = std::conditional_t::value, void_type, T>; - - template using rebind_type5 = Output; - template - using rebind_type4 = std::conditional_t< // - std::is_volatile::value, // - std::add_volatile_t>>, // - rebind_type5>; - template - using rebind_type3 = std::conditional_t< // - std::is_const::value, // - std::add_const_t>>, // - rebind_type4>; - template - using rebind_type2 = std::conditional_t< // - std::is_lvalue_reference::value, // - std::add_lvalue_reference_t>>, // - rebind_type3>; - template - using rebind_type = std::conditional_t< // - std::is_rvalue_reference::value, // - std::add_rvalue_reference_t>>, // - rebind_type2>; - - // static_assert(std::is_same_v, volatile const int &&>, ""); - - - /* True if type is the same or constructible. Works around a bug where clang + libstdc++ - pukes on std::is_constructible (this bug is fixed upstream). - */ - template struct _is_explicitly_constructible - { - static constexpr bool value = std::is_constructible::value; - }; - template struct _is_explicitly_constructible - { - static constexpr bool value = false; - }; - template <> struct _is_explicitly_constructible - { - static constexpr bool value = false; - }; - template static constexpr bool is_explicitly_constructible = _is_explicitly_constructible::value; - - template struct _is_implicitly_constructible - { - static constexpr bool value = std::is_convertible::value; - }; - template struct _is_implicitly_constructible - { - static constexpr bool value = false; - }; - template <> struct _is_implicitly_constructible - { - static constexpr bool value = false; - }; - template static constexpr bool is_implicitly_constructible = _is_implicitly_constructible::value; - - template struct _is_nothrow_constructible - { - static constexpr bool value = std::is_nothrow_constructible::value; - }; - template struct _is_nothrow_constructible - { - static constexpr bool value = false; - }; - template <> struct _is_nothrow_constructible - { - static constexpr bool value = false; - }; - template static constexpr bool is_nothrow_constructible = _is_nothrow_constructible::value; - - template struct _is_constructible - { - static constexpr bool value = std::is_constructible::value; - }; - template struct _is_constructible - { - static constexpr bool value = false; - }; - template <> struct _is_constructible - { - static constexpr bool value = false; - }; - template static constexpr bool is_constructible = _is_constructible::value; - -#ifndef BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE -#if defined(_MSC_VER) && _HAS_CXX17 -#define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 1 // MSVC always has std::is_nothrow_swappable -#elif __cplusplus >= 201700 -// libstdc++ before GCC 6 doesn't have it, despite claiming C++ 17 support -#ifdef __has_include -#if !__has_include() -#define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 0 // must have it if is present -#endif -#endif - -#ifndef BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE -#define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 1 -#endif -#else -#define BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE 0 -#endif -#endif - -// True if type is nothrow swappable -#if !defined(STANDARDESE_IS_IN_THE_HOUSE) && BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE - template using is_nothrow_swappable = std::is_nothrow_swappable; -#else - template struct is_nothrow_swappable - { - static constexpr bool value = std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value; - }; -#endif -} // namespace detail -BOOST_OUTCOME_V2_NAMESPACE_END - -#ifndef BOOST_OUTCOME_THROW_EXCEPTION -#include -#define BOOST_OUTCOME_THROW_EXCEPTION(expr) BOOST_THROW_EXCEPTION(expr) -#endif - -#ifndef BOOST_OUTCOME_AUTO_TEST_CASE -#define BOOST_OUTCOME_AUTO_TEST_CASE(a, b) BOOST_AUTO_TEST_CASE(a) -#endif - -#endif diff --git a/boost/outcome/convert.hpp b/boost/outcome/convert.hpp deleted file mode 100755 index 22ca80c0f23c96f721c9329577b28c41382cfa3e..0000000000000000000000000000000000000000 --- a/boost/outcome/convert.hpp +++ /dev/null @@ -1,167 +0,0 @@ -/* Says how to convert value, error and exception types -(C) 2017-2020 Niall Douglas (12 commits) -File Created: Nov 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_CONVERT_HPP -#define BOOST_OUTCOME_CONVERT_HPP - -#include "detail/basic_result_storage.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace concepts -{ -#if defined(__cpp_concepts) -#if !defined(_MSC_VER) && !defined(__clang__) && __GNUC__ < 10 -#define BOOST_OUTCOME_GCC6_CONCEPT_BOOL bool -#else -#define BOOST_OUTCOME_GCC6_CONCEPT_BOOL -#endif - namespace detail - { - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL SameHelper = std::is_same::value; - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL same_as = detail::SameHelper &&detail::SameHelper; - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL convertible = std::is_convertible::value; - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL base_of = std::is_base_of::value; - } // namespace detail - - - /* The `value_or_none` concept. - \requires That `U::value_type` exists and that `std::declval().has_value()` returns a `bool` and `std::declval().value()` exists. - */ - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL value_or_none = requires(U a) - { - { - a.has_value() - } - ->detail::same_as; - {a.value()}; - }; - /* The `value_or_error` concept. - \requires That `U::value_type` and `U::error_type` exist; - that `std::declval().has_value()` returns a `bool`, `std::declval().value()` and `std::declval().error()` exists. - */ - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL value_or_error = requires(U a) - { - { - a.has_value() - } - ->detail::same_as; - {a.value()}; - {a.error()}; - }; - -#else - namespace detail - { - struct no_match - { - }; - inline no_match match_value_or_none(...); - inline no_match match_value_or_error(...); - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval().has_value()), BOOST_OUTCOME_TEXPR(std::declval().value())) - inline U match_value_or_none(U &&); - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval().has_value()), BOOST_OUTCOME_TEXPR(std::declval().value()), BOOST_OUTCOME_TEXPR(std::declval().error())) - inline U match_value_or_error(U &&); - - template - static constexpr bool value_or_none = - !std::is_same>()))>::value; - template - static constexpr bool value_or_error = - !std::is_same>()))>::value; - } // namespace detail - /* The `value_or_none` concept. - \requires That `U::value_type` exists and that `std::declval().has_value()` returns a `bool` and `std::declval().value()` exists. - */ - template static constexpr bool value_or_none = detail::value_or_none; - /* The `value_or_error` concept. - \requires That `U::value_type` and `U::error_type` exist; - that `std::declval().has_value()` returns a `bool`, `std::declval().value()` and `std::declval().error()` exists. - */ - template static constexpr bool value_or_error = detail::value_or_error; -#endif -} // namespace concepts - -namespace convert -{ -#if BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR < 220 -#if defined(__cpp_concepts) - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL ValueOrNone = concepts::value_or_none; - template concept BOOST_OUTCOME_GCC6_CONCEPT_BOOL ValueOrError = concepts::value_or_error; -#else - template static constexpr bool ValueOrNone = concepts::value_or_none; - template static constexpr bool ValueOrError = concepts::value_or_error; -#endif -#endif - - namespace detail - { - template struct make_type - { - template static constexpr T value(U &&v) { return T{in_place_type, static_cast(v).value()}; } - template static constexpr T error(U &&v) { return T{in_place_type, static_cast(v).error()}; } - static constexpr T error() { return T{in_place_type}; } - }; - template struct make_type - { - template static constexpr T value(U && /*unused*/) { return T{in_place_type}; } - template static constexpr T error(U && /*unused*/) { return T{in_place_type}; } - static constexpr T error() { return T{in_place_type}; } - }; - } // namespace detail - - /*! AWAITING HUGO JSON CONVERSION TOOL -type definition value_or_error. Potential doc page: NOT FOUND -*/ - template struct value_or_error - { - static constexpr bool enable_result_inputs = false; - static constexpr bool enable_outcome_inputs = false; - BOOST_OUTCOME_TEMPLATE(class X) - BOOST_OUTCOME_TREQUIRES( - BOOST_OUTCOME_TPRED(std::is_same>::value // - &&concepts::value_or_error // - && (std::is_void::value_type>::value || - BOOST_OUTCOME_V2_NAMESPACE::detail::is_explicitly_constructible::value_type>) // - &&(std::is_void::error_type>::value || - BOOST_OUTCOME_V2_NAMESPACE::detail::is_explicitly_constructible::error_type>) )) - constexpr T operator()(X &&v) - { - return v.has_value() ? detail::make_type::value(static_cast(v)) : - detail::make_type::error(static_cast(v)); - } - }; -} // namespace convert - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/coroutine_support.hpp b/boost/outcome/coroutine_support.hpp deleted file mode 100755 index 433126d23ca89b4d5f8dbe200403633aba153c39..0000000000000000000000000000000000000000 --- a/boost/outcome/coroutine_support.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* Tells C++ coroutines about Outcome's result -(C) 2019-2020 Niall Douglas (12 commits) -File Created: Oct 2019 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_COROUTINE_SUPPORT_HPP -#define BOOST_OUTCOME_COROUTINE_SUPPORT_HPP - -#include "config.hpp" - -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_BEGIN \ - BOOST_OUTCOME_V2_NAMESPACE_BEGIN namespace awaitables \ - { -// -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_EXPORT_BEGIN \ - BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN namespace awaitables \ - { -// -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_END \ - } \ - BOOST_OUTCOME_V2_NAMESPACE_END - -#ifndef BOOST_NO_EXCEPTIONS -#include "utils.hpp" -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -namespace awaitables -{ - namespace detail - { - inline bool error_is_set(std::error_code ec) noexcept { return !!ec; } - inline std::error_code error_from_exception(std::exception_ptr &&ep, std::error_code not_matched) noexcept { return BOOST_OUTCOME_V2_NAMESPACE::error_from_exception(static_cast(ep), not_matched); } - } // namespace detail -} // namespace awaitables -BOOST_OUTCOME_V2_NAMESPACE_END -#endif - -#include "detail/coroutine_support.ipp" - -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_BEGIN -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_EXPORT_BEGIN -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/basic_outcome_exception_observers.hpp b/boost/outcome/detail/basic_outcome_exception_observers.hpp deleted file mode 100755 index 5040a9f416691a4cb1db2e421e37b983fb90ae90..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/basic_outcome_exception_observers.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Exception observers for outcome type -(C) 2017-2020 Niall Douglas (3 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BASIC_OUTCOME_EXCEPTION_OBSERVERS_HPP -#define BOOST_OUTCOME_BASIC_OUTCOME_EXCEPTION_OBSERVERS_HPP - -#include "basic_result_storage.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace detail -{ - template class basic_outcome_exception_observers : public Base - { - public: - using exception_type = P; - using Base::Base; - - constexpr inline exception_type &assume_exception() & noexcept; - constexpr inline const exception_type &assume_exception() const &noexcept; - constexpr inline exception_type &&assume_exception() && noexcept; - constexpr inline const exception_type &&assume_exception() const &&noexcept; - - constexpr inline exception_type &exception() &; - constexpr inline const exception_type &exception() const &; - constexpr inline exception_type &&exception() &&; - constexpr inline const exception_type &&exception() const &&; - }; - - // Exception observers not present - template class basic_outcome_exception_observers : public Base - { - public: - using Base::Base; - constexpr void assume_exception() const noexcept { NoValuePolicy::narrow_exception_check(this); } - constexpr void exception() const { NoValuePolicy::wide_exception_check(this); } - }; - -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/basic_outcome_exception_observers_impl.hpp b/boost/outcome/detail/basic_outcome_exception_observers_impl.hpp deleted file mode 100755 index e53f8775d397b1e521a027705691bee3f559831f..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/basic_outcome_exception_observers_impl.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/* Exception observers for outcome type -(C) 2017-2020 Niall Douglas (6 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BASIC_OUTCOME_EXCEPTION_OBSERVERS_IMPL_HPP -#define BOOST_OUTCOME_BASIC_OUTCOME_EXCEPTION_OBSERVERS_IMPL_HPP - -#include "basic_outcome_exception_observers.hpp" - -#include "../policy/base.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace policy -{ - template inline constexpr auto &&base::_exception(Impl &&self) noexcept - { - // Impl will be some internal implementation class which has no knowledge of the _ptr stored - // beneath it. So statically cast, preserving rvalue and constness, to the derived class. - using Outcome = BOOST_OUTCOME_V2_NAMESPACE::detail::rebind_type, decltype(self)>; -#if defined(_MSC_VER) && _MSC_VER < 1920 - // VS2017 tries a copy construction in the correct implementation despite that Outcome is always a rvalue or lvalue ref! :( - basic_outcome &_self = (basic_outcome &) (self); // NOLINT -#else - Outcome _self = static_cast(self); // NOLINT -#endif - return static_cast(_self)._ptr; - } -} // namespace policy - -namespace detail -{ - template inline constexpr typename basic_outcome_exception_observers::exception_type &basic_outcome_exception_observers::assume_exception() & noexcept - { - NoValuePolicy::narrow_exception_check(*this); - return NoValuePolicy::template _exception(*this); - } - template inline constexpr const typename basic_outcome_exception_observers::exception_type &basic_outcome_exception_observers::assume_exception() const &noexcept - { - NoValuePolicy::narrow_exception_check(*this); - return NoValuePolicy::template _exception(*this); - } - template inline constexpr typename basic_outcome_exception_observers::exception_type &&basic_outcome_exception_observers::assume_exception() && noexcept - { - NoValuePolicy::narrow_exception_check(std::move(*this)); - return NoValuePolicy::template _exception(std::move(*this)); - } - template inline constexpr const typename basic_outcome_exception_observers::exception_type &&basic_outcome_exception_observers::assume_exception() const &&noexcept - { - NoValuePolicy::narrow_exception_check(std::move(*this)); - return NoValuePolicy::template _exception(std::move(*this)); - } - - template inline constexpr typename basic_outcome_exception_observers::exception_type &basic_outcome_exception_observers::exception() & - { - NoValuePolicy::wide_exception_check(*this); - return NoValuePolicy::template _exception(*this); - } - template inline constexpr const typename basic_outcome_exception_observers::exception_type &basic_outcome_exception_observers::exception() const & - { - NoValuePolicy::wide_exception_check(*this); - return NoValuePolicy::template _exception(*this); - } - template inline constexpr typename basic_outcome_exception_observers::exception_type &&basic_outcome_exception_observers::exception() && - { - NoValuePolicy::wide_exception_check(std::move(*this)); - return NoValuePolicy::template _exception(std::move(*this)); - } - template inline constexpr const typename basic_outcome_exception_observers::exception_type &&basic_outcome_exception_observers::exception() const && - { - NoValuePolicy::wide_exception_check(std::move(*this)); - return NoValuePolicy::template _exception(std::move(*this)); - } -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/basic_outcome_failure_observers.hpp b/boost/outcome/detail/basic_outcome_failure_observers.hpp deleted file mode 100755 index 819f7376a04a042f46bbf576e531bad4ce26d455..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/basic_outcome_failure_observers.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* Failure observers for outcome type -(C) 2017-2020 Niall Douglas (7 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BASIC_OUTCOME_FAILURE_OBSERVERS_HPP -#define BOOST_OUTCOME_BASIC_OUTCOME_FAILURE_OBSERVERS_HPP - -#include "basic_result_storage.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace detail -{ - namespace adl - { - struct search_detail_adl - { - }; - // Do NOT use template requirements here! - template ()))> - inline auto _delayed_lookup_basic_outcome_failure_exception_from_error(const S &ec, search_detail_adl /*unused*/) - { - // ADL discovered - return basic_outcome_failure_exception_from_error(ec); - } - } // namespace adl -#if defined(_MSC_VER) && _MSC_VER <= 1923 // VS2019 - // VS2017 and VS2019 with /permissive- chokes on the correct form due to over eager early instantiation. - template inline void _delayed_lookup_basic_outcome_failure_exception_from_error(...) { static_assert(sizeof(S) == 0, "No specialisation for these error and exception types available!"); } -#else - template inline void _delayed_lookup_basic_outcome_failure_exception_from_error(...) = delete; // NOLINT No specialisation for these error and exception types available! -#endif - - template inline exception_type current_exception_or_fatal(std::exception_ptr e) { std::rethrow_exception(e); } - template <> inline std::exception_ptr current_exception_or_fatal(std::exception_ptr e) { return e; } - - template class basic_outcome_failure_observers : public Base - { - public: - using exception_type = P; - using Base::Base; - - exception_type failure() const noexcept - { -#ifndef BOOST_NO_EXCEPTIONS - try -#endif - { - if(this->_state._status.have_exception()) - { - return this->assume_exception(); - } - if(this->_state._status.have_error()) - { - return _delayed_lookup_basic_outcome_failure_exception_from_error(this->assume_error(), adl::search_detail_adl()); - } - return exception_type(); - } -#ifndef BOOST_NO_EXCEPTIONS - catch(...) - { - // Return the failure if exception_type is std::exception_ptr, - // otherwise terminate same as throwing an exception inside noexcept - return current_exception_or_fatal(std::current_exception()); - } -#endif - } - }; - -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/basic_result_final.hpp b/boost/outcome/detail/basic_result_final.hpp deleted file mode 100755 index f54e321438255058da54aec0bceb77db4646e8fb..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/basic_result_final.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* Finaliser for a very simple result type -(C) 2017-2020 Niall Douglas (5 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_BASIC_RESULT_FINAL_HPP -#define BOOST_OUTCOME_BASIC_RESULT_FINAL_HPP - -#include "basic_result_error_observers.hpp" -#include "basic_result_value_observers.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace detail -{ - template using select_basic_result_impl = basic_result_error_observers, R, NoValuePolicy>, EC, NoValuePolicy>; - - template - class basic_result_final -#if defined(BOOST_OUTCOME_DOXYGEN_IS_IN_THE_HOUSE) - : public basic_result_error_observers, R, NoValuePolicy>, S, NoValuePolicy> -#else - : public select_basic_result_impl -#endif - { - using base = select_basic_result_impl; - - public: - using base::base; - - constexpr explicit operator bool() const noexcept { return this->_state._status.have_value(); } - constexpr bool has_value() const noexcept { return this->_state._status.have_value(); } - constexpr bool has_error() const noexcept { return this->_state._status.have_error(); } - constexpr bool has_exception() const noexcept { return this->_state._status.have_exception(); } - constexpr bool has_lost_consistency() const noexcept { return this->_state._status.have_lost_consistency(); } - constexpr bool has_failure() const noexcept { return this->_state._status.have_error() || this->_state._status.have_exception(); } - - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() == std::declval>())) - constexpr bool operator==(const basic_result_final &o) const noexcept( // - noexcept(std::declval>() == std::declval>()) && noexcept(std::declval>() == std::declval>())) - { - if(this->_state._status.have_value() && o._state._status.have_value()) - { - return this->_state._value == o._state._value; // NOLINT - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error == o._error; - } - return false; - } - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() == std::declval())) - constexpr bool operator==(const success_type &o) const noexcept( // - noexcept(std::declval() == std::declval())) - { - if(this->_state._status.have_value()) - { - return this->_state._value == o.value(); - } - return false; - } - constexpr bool operator==(const success_type &o) const noexcept - { - (void) o; - return this->_state._status.have_value(); - } - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() == std::declval())) - constexpr bool operator==(const failure_type &o) const noexcept( // - noexcept(std::declval() == std::declval())) - { - if(this->_state._status.have_error()) - { - return this->_error == o.error(); - } - return false; - } - BOOST_OUTCOME_TEMPLATE(class T, class U, class V) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>()), // - BOOST_OUTCOME_TEXPR(std::declval>() != std::declval>())) - constexpr bool operator!=(const basic_result_final &o) const noexcept( // - noexcept(std::declval>() != std::declval>()) && noexcept(std::declval>() != std::declval>())) - { - if(this->_state._status.have_value() && o._state._status.have_value()) - { - return this->_state._value != o._state._value; - } - if(this->_state._status.have_error() && o._state._status.have_error()) - { - return this->_error != o._error; - } - return true; - } - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() != std::declval())) - constexpr bool operator!=(const success_type &o) const noexcept( // - noexcept(std::declval() != std::declval())) - { - if(this->_state._status.have_value()) - { - return this->_state._value != o.value(); - } - return false; - } - constexpr bool operator!=(const success_type &o) const noexcept - { - (void) o; - return !this->_state._status.have_value(); - } - BOOST_OUTCOME_TEMPLATE(class T) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TEXPR(std::declval() != std::declval())) - constexpr bool operator!=(const failure_type &o) const noexcept( // - noexcept(std::declval() != std::declval())) - { - if(this->_state._status.have_error()) - { - return this->_error != o.error(); - } - return true; - } - }; - template constexpr inline bool operator==(const success_type &a, const basic_result_final &b) noexcept(noexcept(b == a)) { return b == a; } - template constexpr inline bool operator==(const failure_type &a, const basic_result_final &b) noexcept(noexcept(b == a)) { return b == a; } - template constexpr inline bool operator!=(const success_type &a, const basic_result_final &b) noexcept(noexcept(b == a)) { return b != a; } - template constexpr inline bool operator!=(const failure_type &a, const basic_result_final &b) noexcept(noexcept(b == a)) { return b != a; } -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/basic_result_value_observers.hpp b/boost/outcome/detail/basic_result_value_observers.hpp deleted file mode 100755 index 9e9779aa2e41af042e4a4b3ffbe56d1d224e1470..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/basic_result_value_observers.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* Value observers for a very simple basic_result type -(C) 2017-2020 Niall Douglas (2 commits) -File Created: Oct 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_RESULT_VALUE_OBSERVERS_HPP -#define BOOST_OUTCOME_RESULT_VALUE_OBSERVERS_HPP - -#include "basic_result_storage.hpp" - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN - -namespace detail -{ - template class basic_result_value_observers : public Base - { - public: - using value_type = R; - using Base::Base; - - constexpr value_type &assume_value() & noexcept - { - NoValuePolicy::narrow_value_check(static_cast(*this)); - return this->_state._value; // NOLINT - } - constexpr const value_type &assume_value() const &noexcept - { - NoValuePolicy::narrow_value_check(static_cast(*this)); - return this->_state._value; // NOLINT - } - constexpr value_type &&assume_value() && noexcept - { - NoValuePolicy::narrow_value_check(static_cast(*this)); - return static_cast(this->_state._value); // NOLINT - } - constexpr const value_type &&assume_value() const &&noexcept - { - NoValuePolicy::narrow_value_check(static_cast(*this)); - return static_cast(this->_state._value); // NOLINT - } - - constexpr value_type &value() & - { - NoValuePolicy::wide_value_check(static_cast(*this)); - return this->_state._value; // NOLINT - } - constexpr const value_type &value() const & - { - NoValuePolicy::wide_value_check(static_cast(*this)); - return this->_state._value; // NOLINT - } - constexpr value_type &&value() && - { - NoValuePolicy::wide_value_check(static_cast(*this)); - return static_cast(this->_state._value); // NOLINT - } - constexpr const value_type &&value() const && - { - NoValuePolicy::wide_value_check(static_cast(*this)); - return static_cast(this->_state._value); // NOLINT - } - }; - template class basic_result_value_observers : public Base - { - public: - using Base::Base; - - constexpr void assume_value() const noexcept { NoValuePolicy::narrow_value_check(*this); } - constexpr void value() const { NoValuePolicy::wide_value_check(*this); } - }; -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/coroutine_support.ipp b/boost/outcome/detail/coroutine_support.ipp deleted file mode 100755 index 989f599aa2cf2a2f75651b7451adec5541f30d19..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/coroutine_support.ipp +++ /dev/null @@ -1,333 +0,0 @@ -/* Tells C++ coroutines about Outcome's result -(C) 2019-2020 Niall Douglas (12 commits) -File Created: Oct 2019 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_BEGIN -#error This header must only be included by outcome/coroutine_support.hpp or outcome/experimental/coroutine_support.hpp -#endif - -#ifndef BOOST_OUTCOME_DETAIL_COROUTINE_SUPPORT_HPP -#define BOOST_OUTCOME_DETAIL_COROUTINE_SUPPORT_HPP - -#include -#include - -#if __cpp_impl_coroutine || (defined(_MSC_VER) && __cpp_coroutines) || (defined(__clang__) && __cpp_coroutines) -#if __has_include() -#include -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -namespace awaitables -{ - template using coroutine_handle = std::coroutine_handle; - template using coroutine_traits = std::coroutine_traits; - using std::suspend_always; - using std::suspend_never; -} // namespace awaitables -BOOST_OUTCOME_V2_NAMESPACE_END -#define BOOST_OUTCOME_FOUND_COROUTINE_HEADER 1 -#elif __has_include() -#include -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -namespace awaitables -{ - template using coroutine_handle = std::experimental::coroutine_handle; - template using coroutine_traits = std::experimental::coroutine_traits; - using std::experimental::suspend_always; - using std::experimental::suspend_never; -} // namespace awaitables -BOOST_OUTCOME_V2_NAMESPACE_END -#define BOOST_OUTCOME_FOUND_COROUTINE_HEADER 1 -#endif -#endif - -BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN -namespace awaitables -{ - namespace detail - { - struct error_type_not_found - { - }; - struct exception_type_not_found - { - }; - template struct type_found - { - using type = T; - }; - template constexpr inline type_found extract_error_type(int /*unused*/) { return {}; } - template constexpr inline type_found extract_error_type(...) { return {}; } - template constexpr inline type_found extract_exception_type(int /*unused*/) { return {}; } - template constexpr inline type_found extract_exception_type(...) { return {}; } - - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(BOOST_OUTCOME_V2_NAMESPACE::detail::is_constructible)) - inline bool try_set_error(T &&e, U *result) - { - new(result) U(static_cast(e)); - return true; - } - template inline bool try_set_error(T && /*unused*/, ...) { return false; } - BOOST_OUTCOME_TEMPLATE(class T, class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(BOOST_OUTCOME_V2_NAMESPACE::detail::is_constructible)) - inline void set_or_rethrow(T &e, U *result) { new(result) U(e); } - template inline void set_or_rethrow(T &e, ...) { rethrow_exception(e); } - template class fake_atomic - { - T _v; - - public: - constexpr fake_atomic(T v) - : _v(v) - { - } - T load(std::memory_order /*unused*/) { return _v; } - void store(T v, std::memory_order /*unused*/) { _v = v; } - }; - -#ifdef BOOST_OUTCOME_FOUND_COROUTINE_HEADER - template struct outcome_promise_type - { - using container_type = typename Awaitable::container_type; - using result_set_type = std::conditional_t, fake_atomic>; - union { - BOOST_OUTCOME_V2_NAMESPACE::detail::empty_type _default{}; - container_type result; - }; - result_set_type result_set{false}; - coroutine_handle<> continuation; - - outcome_promise_type() {} - outcome_promise_type(const outcome_promise_type &) = delete; - outcome_promise_type(outcome_promise_type &&) = delete; - outcome_promise_type &operator=(const outcome_promise_type &) = delete; - outcome_promise_type &operator=(outcome_promise_type &&) = delete; - ~outcome_promise_type() - { - if(result_set.load(std::memory_order_acquire)) - { - result.~container_type(); - } - } - auto get_return_object() { return Awaitable{*this}; } - void return_value(container_type &&value) - { - assert(!result_set.load(std::memory_order_acquire)); - if(result_set.load(std::memory_order_acquire)) - { - result.~container_type(); - } - new(&result) container_type(static_cast(value)); - result_set.store(true, std::memory_order_release); - } - void return_value(const container_type &value) - { - assert(!result_set.load(std::memory_order_acquire)); - if(result_set.load(std::memory_order_acquire)) - { - result.~container_type(); - } - new(&result) container_type(value); - result_set.store(true, std::memory_order_release); - } - void unhandled_exception() - { - assert(!result_set.load(std::memory_order_acquire)); - if(result_set.load(std::memory_order_acquire)) - { - result.~container_type(); - } -#ifndef BOOST_NO_EXCEPTIONS - auto e = std::current_exception(); - auto ec = detail::error_from_exception(static_cast(e), {}); - // Try to set error code first - if(!detail::error_is_set(ec) || !detail::try_set_error(static_cast(ec), &result)) - { - detail::set_or_rethrow(e, &result); - } -#else - std::terminate(); -#endif - result_set.store(true, std::memory_order_release); - } - auto initial_suspend() noexcept - { - struct awaiter - { - bool await_ready() noexcept { return !suspend_initial; } - void await_resume() noexcept {} - void await_suspend(coroutine_handle<> /*unused*/) {} - }; - return awaiter{}; - } - auto final_suspend() - { - struct awaiter - { - bool await_ready() noexcept { return false; } - void await_resume() noexcept {} - void await_suspend(coroutine_handle self) - { - if(self.promise().continuation) - { - return self.promise().continuation.resume(); - } - } - }; - return awaiter{}; - } - }; - template struct outcome_promise_type - { - using container_type = void; - using result_set_type = std::conditional_t, fake_atomic>; - result_set_type result_set{false}; - coroutine_handle<> continuation; - - outcome_promise_type() {} - outcome_promise_type(const outcome_promise_type &) = delete; - outcome_promise_type(outcome_promise_type &&) = delete; - outcome_promise_type &operator=(const outcome_promise_type &) = delete; - outcome_promise_type &operator=(outcome_promise_type &&) = delete; - ~outcome_promise_type() = default; - auto get_return_object() { return Awaitable{*this}; } - void return_void() - { - assert(!result_set.load(std::memory_order_acquire)); - result_set.store(true, std::memory_order_release); - } - void unhandled_exception() - { - assert(!result_set.load(std::memory_order_acquire)); - std::rethrow_exception(std::current_exception()); - } - auto initial_suspend() noexcept - { - struct awaiter - { - bool await_ready() noexcept { return !suspend_initial; } - void await_resume() noexcept {} - void await_suspend(coroutine_handle<> /*unused*/) {} - }; - return awaiter{}; - } - auto final_suspend() - { - struct awaiter - { - bool await_ready() noexcept { return false; } - void await_resume() noexcept {} - void await_suspend(coroutine_handle self) - { - if(self.promise().continuation) - { - return self.promise().continuation.resume(); - } - } - }; - return awaiter{}; - } - }; - template constexpr inline auto move_result_from_promise_if_not_void(outcome_promise_type &p) { return static_cast(p.result); } - template constexpr inline void move_result_from_promise_if_not_void(outcome_promise_type & /*unused*/) {} - - template struct BOOST_OUTCOME_NODISCARD awaitable - { - using container_type = Cont; - using promise_type = outcome_promise_type::value>; - coroutine_handle _h; - - awaitable(awaitable &&o) noexcept - : _h(static_cast &&>(o._h)) - { - o._h = nullptr; - } - awaitable(const awaitable &o) = delete; - awaitable &operator=(awaitable &&) = delete; // as per P1056 - awaitable &operator=(const awaitable &) = delete; - ~awaitable() - { - if(_h) - { - _h.destroy(); - } - } - explicit awaitable(promise_type &p) - : _h(coroutine_handle::from_promise(p)) - { - } - bool await_ready() noexcept { return _h.promise().result_set.load(std::memory_order_acquire); } - container_type await_resume() - { - assert(_h.promise().result_set.load(std::memory_order_acquire)); - if(!_h.promise().result_set.load(std::memory_order_acquire)) - { - std::terminate(); - } - return detail::move_result_from_promise_if_not_void(_h.promise()); - } - void await_suspend(coroutine_handle<> cont) - { - _h.promise().continuation = cont; - _h.resume(); - } - }; -#endif - } // namespace detail - -} // namespace awaitables - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif - -#ifdef BOOST_OUTCOME_FOUND_COROUTINE_HEADER -BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_EXPORT_BEGIN -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template using eager = BOOST_OUTCOME_V2_NAMESPACE::awaitables::detail::awaitable; - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template using atomic_eager = BOOST_OUTCOME_V2_NAMESPACE::awaitables::detail::awaitable; - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template using lazy = BOOST_OUTCOME_V2_NAMESPACE::awaitables::detail::awaitable; - -/*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ -template using atomic_lazy = BOOST_OUTCOME_V2_NAMESPACE::awaitables::detail::awaitable; - -BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_END -#endif diff --git a/boost/outcome/detail/trait_std_error_code.hpp b/boost/outcome/detail/trait_std_error_code.hpp deleted file mode 100755 index 18d430f99cfcadaca3ed389528da9f141df5daa4..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/trait_std_error_code.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/* Traits for Outcome -(C) 2018-2020 Niall Douglas (6 commits) -File Created: March 2018 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_TRAIT_STD_ERROR_CODE_HPP -#define BOOST_OUTCOME_TRAIT_STD_ERROR_CODE_HPP - -#include "../config.hpp" - -#include - -BOOST_OUTCOME_V2_NAMESPACE_BEGIN - -namespace detail -{ - // Customise _set_error_is_errno - template constexpr inline void _set_error_is_errno(State &state, const std::error_code &error) - { - if(error.category() == std::generic_category() -#ifndef _WIN32 - || error.category() == std::system_category() -#endif - ) - { - state._status.set_have_error_is_errno(true); - } - } - template constexpr inline void _set_error_is_errno(State &state, const std::error_condition &error) - { - if(error.category() == std::generic_category() -#ifndef _WIN32 - || error.category() == std::system_category() -#endif - ) - { - state._status.set_have_error_is_errno(true); - } - } - template constexpr inline void _set_error_is_errno(State &state, const std::errc & /*unused*/) { - state._status.set_have_error_is_errno(true); - } - -} // namespace detail - -namespace policy -{ - namespace detail - { - /* Pass through `make_error_code` function for `std::error_code`. - */ - inline std::error_code make_error_code(std::error_code v) { return v; } - - // Try ADL, if not use fall backs above - template constexpr inline decltype(auto) error_code(T &&v) { return make_error_code(std::forward(v)); } - - struct std_enum_overload_tag - { - }; - } // namespace detail - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template constexpr inline decltype(auto) error_code(T &&v) { return detail::error_code(std::forward(v)); } - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - // inline void outcome_throw_as_system_error_with_payload(...) = delete; // To use the error_code_throw_as_system_error policy with a custom Error type, you must define a outcome_throw_as_system_error_with_payload() free function to say how to handle the payload - inline void outcome_throw_as_system_error_with_payload(const std::error_code &error) { BOOST_OUTCOME_THROW_EXCEPTION(std::system_error(error)); } // NOLINT - BOOST_OUTCOME_TEMPLATE(class Error) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_error_code_enum>::value || std::is_error_condition_enum>::value)) - inline void outcome_throw_as_system_error_with_payload(Error &&error, detail::std_enum_overload_tag /*unused*/ = detail::std_enum_overload_tag()) { BOOST_OUTCOME_THROW_EXCEPTION(std::system_error(make_error_code(error))); } // NOLINT -} // namespace policy - -namespace trait -{ - namespace detail - { - template <> struct _is_error_code_available - { - // Shortcut this for lower build impact - static constexpr bool value = true; - using type = std::error_code; - }; - } // namespace detail - - // std::error_code is an error type - template <> struct is_error_type - { - static constexpr bool value = true; - }; - // For std::error_code, std::is_error_condition_enum<> is the trait we want. - template struct is_error_type_enum - { - static constexpr bool value = std::is_error_condition_enum::value; - }; - -} // namespace trait - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/trait_std_exception.hpp b/boost/outcome/detail/trait_std_exception.hpp deleted file mode 100755 index 3fdce3e3240aff79b36b7bbdb7b7e4cda606f422..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/trait_std_exception.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* Traits for Outcome -(C) 2018-2020 Niall Douglas (3 commits) -File Created: March 2018 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_TRAIT_STD_EXCEPTION_HPP -#define BOOST_OUTCOME_TRAIT_STD_EXCEPTION_HPP - -#include "../config.hpp" - -#include - -BOOST_OUTCOME_V2_NAMESPACE_BEGIN - -namespace policy -{ - namespace detail - { - /* Pass through `make_exception_ptr` function for `std::exception_ptr`. - */ - inline std::exception_ptr make_exception_ptr(std::exception_ptr v) { return v; } - - // Try ADL, if not use fall backs above - template constexpr inline decltype(auto) exception_ptr(T &&v) { return make_exception_ptr(std::forward(v)); } - } // namespace detail - - /*! AWAITING HUGO JSON CONVERSION TOOL -SIGNATURE NOT RECOGNISED -*/ - template constexpr inline decltype(auto) exception_ptr(T &&v) { return detail::exception_ptr(std::forward(v)); } - - namespace detail - { - template struct _rethrow_exception - { - template explicit _rethrow_exception(Exception && /*unused*/) // NOLINT - { - } - }; - template <> struct _rethrow_exception - { - template explicit _rethrow_exception(Exception &&excpt) // NOLINT - { - // ADL - rethrow_exception(policy::exception_ptr(std::forward(excpt))); - } - }; - } // namespace detail -} // namespace policy - -namespace trait -{ - namespace detail - { - // Shortcut this for lower build impact - template <> struct _is_exception_ptr_available - { - static constexpr bool value = true; - using type = std::exception_ptr; - }; - } // namespace detail - - // std::exception_ptr is an error type - template <> struct is_error_type - { - static constexpr bool value = true; - }; - -} // namespace trait - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/detail/value_storage.hpp b/boost/outcome/detail/value_storage.hpp deleted file mode 100755 index cf7a65320cf4ebd4d25a19f59ada5035380f68a8..0000000000000000000000000000000000000000 --- a/boost/outcome/detail/value_storage.hpp +++ /dev/null @@ -1,1086 +0,0 @@ -/* Essentially an internal optional implementation :) -(C) 2017-2020 Niall Douglas (24 commits) -File Created: June 2017 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_VALUE_STORAGE_HPP -#define BOOST_OUTCOME_VALUE_STORAGE_HPP - -#include "../config.hpp" - -#include - -BOOST_OUTCOME_V2_NAMESPACE_BEGIN - -namespace detail -{ - template struct strong_swap_impl - { - constexpr strong_swap_impl(bool &allgood, T &a, T &b) - { - allgood = true; - using std::swap; - swap(a, b); - } - }; -#ifndef BOOST_NO_EXCEPTIONS - template struct strong_swap_impl - { - strong_swap_impl(bool &allgood, T &a, T &b) - { - allgood = true; - T v(static_cast(a)); - try - { - a = static_cast(b); - } - catch(...) - { - // Try to put back a - try - { - a = static_cast(v); - // fall through as all good - } - catch(...) - { - // failed to completely restore - allgood = false; - // throw away second exception - } - throw; // rethrow original exception - } - // b has been moved to a, try to move v to b - try - { - b = static_cast(v); - } - catch(...) - { - // Try to restore a to b, and v to a - try - { - b = static_cast(a); - a = static_cast(v); - // fall through as all good - } - catch(...) - { - // failed to completely restore - allgood = false; - // throw away second exception - } - throw; // rethrow original exception - } - } - }; -#endif -} // namespace detail - -/*! - */ -BOOST_OUTCOME_TEMPLATE(class T) -BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(std::is_move_constructible::value &&std::is_move_assignable::value)) -constexpr inline void strong_swap(bool &allgood, T &a, T &b) noexcept(detail::is_nothrow_swappable::value) -{ - detail::strong_swap_impl::value>(allgood, a, b); -} - -namespace detail -{ - template - constexpr -#ifdef _MSC_VER - __declspec(noreturn) -#elif defined(__GNUC__) || defined(__clang__) - __attribute__((noreturn)) -#endif - void make_ub(T && /*unused*/) - { - assert(false); // NOLINT -#if defined(__GNUC__) || defined(__clang__) - __builtin_unreachable(); -#elif defined(_MSC_VER) - __assume(0); -#endif - } - - /* Outcome v1 used a C bitfield whose values were tracked by compiler optimisers nicely, - but that produces ICEs when used in constexpr. - - Outcome v2.0-v2.1 used a 32 bit integer and manually set and cleared bits. Unfortunately - only GCC's optimiser tracks bit values during constant folding, and only per byte, and - even then unreliably. https://wg21.link/P1886 "Error speed benchmarking" showed just how - poorly clang and MSVC fails to optimise outcome-using code, if you manually set bits. - - Outcome v2.2 therefore uses an enum with fixed values, and constexpr manipulation functions - to change the value to one of the enum's values. This is stupid to look at in source code, - but it make clang's optimiser do the right thing, so it's worth it. - */ -#define BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS 0 - enum class status : uint16_t - { - // WARNING: These bits are not tracked by abi-dumper, but changing them will break ABI! - none = 0, - - have_value = (1U << 0U), - have_error = (1U << 1U), - have_exception = (2U << 1U), - have_error_exception = (3U << 1U), - - // failed to complete a strong swap - have_lost_consistency = (1U << 3U), - have_value_lost_consistency = (1U << 0U) | (1U << 3U), - have_error_lost_consistency = (1U << 1U) | (1U << 3U), - have_exception_lost_consistency = (2U << 1U) | (1U << 3U), - have_error_exception_lost_consistency = (3U << 1U) | (1U << 3U), - - // can errno be set from this error? - have_error_is_errno = (1U << 4U), - have_error_error_is_errno = (1U << 1U) | (1U << 4U), - have_error_exception_error_is_errno = (3U << 1U) | (1U << 4U), - - have_error_lost_consistency_error_is_errno = (1U << 1U) | (1U << 3U) | (1U << 4U), - have_error_exception_lost_consistency_error_is_errno = (3U << 1U) | (1U << 3U) | (1U << 4U), - - // value has been moved from - have_moved_from = (1U << 5U) - }; - struct status_bitfield_type - { - status status_value{status::none}; - uint16_t spare_storage_value{0}; // hooks::spare_storage() - - constexpr status_bitfield_type() = default; - constexpr status_bitfield_type(status v) noexcept - : status_value(v) - { - } // NOLINT - constexpr status_bitfield_type(status v, uint16_t s) noexcept - : status_value(v) - , spare_storage_value(s) - { - } - constexpr status_bitfield_type(const status_bitfield_type &) = default; - constexpr status_bitfield_type(status_bitfield_type &&) = default; - constexpr status_bitfield_type &operator=(const status_bitfield_type &) = default; - constexpr status_bitfield_type &operator=(status_bitfield_type &&) = default; - //~status_bitfield_type() = default; // Do NOT uncomment this, it breaks older clangs! - - constexpr bool have_value() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - return (status_value == status::have_value) // - || (status_value == status::have_value_lost_consistency) // - ; -#else - return (static_cast(status_value) & static_cast(status::have_value)) != 0; -#endif - } - constexpr bool have_error() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - return (status_value == status::have_error) // - || (status_value == status::have_error_exception) // - || (status_value == status::have_error_lost_consistency) // - || (status_value == status::have_error_exception_lost_consistency) // - || (status_value == status::have_error_error_is_errno) // - || (status_value == status::have_error_exception_error_is_errno) // - || (status_value == status::have_error_lost_consistency_error_is_errno) // - || (status_value == status::have_error_exception_lost_consistency_error_is_errno) // - ; -#else - return (static_cast(status_value) & static_cast(status::have_error)) != 0; -#endif - } - constexpr bool have_exception() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - return (status_value == status::have_exception) // - || (status_value == status::have_error_exception) // - || (status_value == status::have_exception_lost_consistency) // - || (status_value == status::have_error_exception_lost_consistency) // - || (status_value == status::have_error_exception_error_is_errno) // - || (status_value == status::have_error_exception_lost_consistency_error_is_errno) // - ; -#else - return (static_cast(status_value) & static_cast(status::have_exception)) != 0; -#endif - } - constexpr bool have_lost_consistency() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - return (status_value == status::have_value_lost_consistency) // - || (status_value == status::have_error_lost_consistency) // - || (status_value == status::have_exception_lost_consistency) // - || (status_value == status::have_error_lost_consistency_error_is_errno) // - || (status_value == status::have_error_exception_lost_consistency_error_is_errno) // - ; -#else - return (static_cast(status_value) & static_cast(status::have_lost_consistency)) != 0; -#endif - } - constexpr bool have_error_is_errno() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - return (status_value == status::have_error_error_is_errno) // - || (status_value == status::have_error_exception_error_is_errno) // - || (status_value == status::have_error_lost_consistency_error_is_errno) // - || (status_value == status::have_error_exception_lost_consistency_error_is_errno) // - ; -#else - return (static_cast(status_value) & static_cast(status::have_error_is_errno)) != 0; -#endif - } - constexpr bool have_moved_from() const noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS -#error Fixme -#else - return (static_cast(status_value) & static_cast(status::have_moved_from)) != 0; -#endif - } - - constexpr status_bitfield_type &set_have_value(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - switch(status_value) - { - case status::none: - if(v) - { - status_value = status::have_value; - } - break; - case status::have_value: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error: - if(v) - { - make_ub(*this); - } - break; - case status::have_exception: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_exception: - if(v) - { - make_ub(*this); - } - break; - case status::have_value_lost_consistency: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error_lost_consistency: - if(v) - { - make_ub(*this); - } - break; - case status::have_exception_lost_consistency: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_exception_lost_consistency: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_error_is_errno: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_exception_error_is_errno: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_lost_consistency_error_is_errno: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_exception_lost_consistency_error_is_errno: - if(v) - { - make_ub(*this); - } - break; - } -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_value)) : - (static_cast(status_value) & ~static_cast(status::have_value))); -#endif - return *this; - } - constexpr status_bitfield_type &set_have_error(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - switch(status_value) - { - case status::none: - if(v) - { - status_value = status::have_error; - } - break; - case status::have_value: - if(v) - { - make_ub(*this); - } - break; - case status::have_error: - if(!v) - { - status_value = status::none; - } - break; - case status::have_exception: - if(v) - { - status_value = status::have_error_exception; - } - break; - case status::have_error_exception: - if(!v) - { - status_value = status::have_exception; - } - break; - case status::have_value_lost_consistency: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_lost_consistency: - if(!v) - { - status_value = status::none; - } - break; - case status::have_exception_lost_consistency: - if(v) - { - status_value = status::have_error_exception_lost_consistency; - } - break; - case status::have_error_exception_lost_consistency: - if(!v) - { - status_value = status::have_exception_lost_consistency; - } - break; - case status::have_error_error_is_errno: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error_exception_error_is_errno: - if(!v) - { - status_value = status::have_exception; - } - break; - case status::have_error_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error_exception_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_exception_lost_consistency; - } - break; - } -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_error)) : - (static_cast(status_value) & ~static_cast(status::have_error))); -#endif - return *this; - } - constexpr status_bitfield_type &set_have_exception(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - switch(status_value) - { - case status::none: - if(v) - { - status_value = status::have_exception; - } - break; - case status::have_value: - if(v) - { - make_ub(*this); - } - break; - case status::have_error: - if(v) - { - status_value = status::have_error_exception; - } - break; - case status::have_exception: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error_exception: - if(!v) - { - status_value = status::have_error; - } - break; - case status::have_value_lost_consistency: - if(v) - { - make_ub(*this); - } - break; - case status::have_error_lost_consistency: - if(v) - { - status_value = status::have_error_exception_lost_consistency; - } - break; - case status::have_exception_lost_consistency: - if(!v) - { - status_value = status::none; - } - break; - case status::have_error_exception_lost_consistency: - if(!v) - { - status_value = status::have_error_lost_consistency; - } - break; - case status::have_error_error_is_errno: - if(v) - { - status_value = status::have_error_exception_error_is_errno; - } - break; - case status::have_error_exception_error_is_errno: - if(!v) - { - status_value = status::have_error_error_is_errno; - } - break; - case status::have_error_lost_consistency_error_is_errno: - if(v) - { - status_value = status::have_error_exception_lost_consistency_error_is_errno; - } - break; - case status::have_error_exception_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_error_lost_consistency_error_is_errno; - } - break; - } -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_exception)) : - (static_cast(status_value) & ~static_cast(status::have_exception))); -#endif - return *this; - } - constexpr status_bitfield_type &set_have_error_is_errno(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - switch(status_value) - { - case status::none: - make_ub(*this); - break; - case status::have_value: - make_ub(*this); - break; - case status::have_error: - if(v) - { - status_value = status::have_error_error_is_errno; - } - break; - case status::have_exception: - make_ub(*this); - break; - case status::have_error_exception: - if(v) - { - status_value = status::have_error_exception_error_is_errno; - } - break; - case status::have_value_lost_consistency: - make_ub(*this); - break; - case status::have_error_lost_consistency: - if(v) - { - status_value = status::have_error_lost_consistency_error_is_errno; - } - break; - case status::have_exception_lost_consistency: - make_ub(*this); - break; - case status::have_error_exception_lost_consistency: - if(v) - { - status_value = status::have_error_exception_lost_consistency_error_is_errno; - } - break; - case status::have_error_error_is_errno: - if(!v) - { - status_value = status::have_error; - } - break; - case status::have_error_exception_error_is_errno: - if(!v) - { - status_value = status::have_error_exception; - } - break; - case status::have_error_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_error_lost_consistency; - } - break; - case status::have_error_exception_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_error_exception_lost_consistency; - } - break; - } -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_error_is_errno)) : - (static_cast(status_value) & ~static_cast(status::have_error_is_errno))); -#endif - return *this; - } - constexpr status_bitfield_type &set_have_lost_consistency(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS - switch(status_value) - { - case status::none: - if(v) - { - make_ub(*this); - } - break; - case status::have_value: - if(v) - { - status_value = status::have_value_lost_consistency; - } - break; - case status::have_error: - if(v) - { - status_value = status::have_error_lost_consistency; - } - break; - case status::have_exception: - if(v) - { - status_value = status::have_exception_lost_consistency; - } - break; - case status::have_error_exception: - if(v) - { - status_value = status::have_error_exception_lost_consistency; - } - break; - case status::have_value_lost_consistency: - if(!v) - { - status_value = status::have_value; - } - break; - case status::have_error_lost_consistency: - if(!v) - { - status_value = status::have_error; - } - break; - case status::have_exception_lost_consistency: - if(!v) - { - status_value = status::have_exception; - } - break; - case status::have_error_exception_lost_consistency: - if(!v) - { - status_value = status::have_error_exception; - } - break; - case status::have_error_error_is_errno: - if(v) - { - status_value = status::have_error_lost_consistency_error_is_errno; - } - break; - case status::have_error_exception_error_is_errno: - if(v) - { - status_value = status::have_error_exception_lost_consistency_error_is_errno; - } - break; - case status::have_error_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_error_exception_error_is_errno; - } - break; - case status::have_error_exception_lost_consistency_error_is_errno: - if(!v) - { - status_value = status::have_error_exception_error_is_errno; - } - break; - } -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_lost_consistency)) : - (static_cast(status_value) & ~static_cast(status::have_lost_consistency))); -#endif - return *this; - } - constexpr status_bitfield_type &set_have_moved_from(bool v) noexcept - { -#if BOOST_OUTCOME_USE_CONSTEXPR_ENUM_STATUS -#error Fixme -#else - status_value = static_cast(v ? (static_cast(status_value) | static_cast(status::have_moved_from)) : - (static_cast(status_value) & ~static_cast(status::have_moved_from))); -#endif - return *this; - } - }; -#if !defined(NDEBUG) - // Check is trivial in all ways except default constructibility - static_assert(sizeof(status_bitfield_type) == 4, "status_bitfield_type is not sized 4 bytes!"); - static_assert(std::is_trivially_copyable::value, "status_bitfield_type is not trivially copyable!"); - static_assert(std::is_trivially_assignable::value, "status_bitfield_type is not trivially assignable!"); - static_assert(std::is_trivially_destructible::value, "status_bitfield_type is not trivially destructible!"); - static_assert(std::is_trivially_copy_constructible::value, "status_bitfield_type is not trivially copy constructible!"); - static_assert(std::is_trivially_move_constructible::value, "status_bitfield_type is not trivially move constructible!"); - static_assert(std::is_trivially_copy_assignable::value, "status_bitfield_type is not trivially copy assignable!"); - static_assert(std::is_trivially_move_assignable::value, "status_bitfield_type is not trivially move assignable!"); - // Also check is standard layout - static_assert(std::is_standard_layout::value, "status_bitfield_type is not a standard layout type!"); -#endif - - // Used if T is trivial - template struct value_storage_trivial - { - using value_type = T; - union { - empty_type _empty; - devoid _value; - }; - status_bitfield_type _status; - constexpr value_storage_trivial() noexcept - : _empty{} - { - } - // Special from-void catchall constructor, always constructs default T irrespective of whether void is valued or not (can do no better if T cannot be - // copied) - struct disable_void_catchall - { - }; - using void_value_storage_trivial = std::conditional_t::value, disable_void_catchall, value_storage_trivial>; - explicit constexpr value_storage_trivial(const void_value_storage_trivial &o) noexcept(std::is_nothrow_default_constructible::value) - : _value() - , _status(o._status) - { - } - value_storage_trivial(const value_storage_trivial &) = default; // NOLINT - value_storage_trivial(value_storage_trivial &&) = default; // NOLINT - value_storage_trivial &operator=(const value_storage_trivial &) = default; // NOLINT - value_storage_trivial &operator=(value_storage_trivial &&) = default; // NOLINT - ~value_storage_trivial() = default; - constexpr explicit value_storage_trivial(status_bitfield_type status) - : _empty() - , _status(status) - { - } - template - constexpr explicit value_storage_trivial(in_place_type_t /*unused*/, - Args &&... args) noexcept(detail::is_nothrow_constructible) - : _value(static_cast(args)...) - , _status(status::have_value) - { - } - template - constexpr value_storage_trivial(in_place_type_t /*unused*/, std::initializer_list il, - Args &&... args) noexcept(detail::is_nothrow_constructible, Args...>) - : _value(il, static_cast(args)...) - , _status(status::have_value) - { - } - template - static constexpr bool enable_converting_constructor = !std::is_same, value_type>::value && detail::is_constructible; - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_trivial(const value_storage_trivial &o) noexcept(detail::is_nothrow_constructible) - : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type, o._value) : value_storage_trivial()) // NOLINT - { - _status = o._status; - } - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_trivial(value_storage_trivial &&o) noexcept(detail::is_nothrow_constructible) - : value_storage_trivial(o._status.have_value() ? value_storage_trivial(in_place_type, static_cast(o._value)) : - value_storage_trivial()) // NOLINT - { - _status = o._status; - } - constexpr void swap(value_storage_trivial &o) noexcept - { - // storage is trivial, so just use assignment - auto temp = static_cast(*this); - *this = static_cast(o); - o = static_cast(temp); - } - }; - // Used if T is non-trivial - template struct value_storage_nontrivial - { - using value_type = T; - union { - empty_type _empty; - value_type _value; - }; - status_bitfield_type _status; - value_storage_nontrivial() noexcept - : _empty{} - { - } - value_storage_nontrivial &operator=(const value_storage_nontrivial &) = default; // if reaches here, copy assignment is trivial - value_storage_nontrivial &operator=(value_storage_nontrivial &&) = default; // NOLINT if reaches here, move assignment is trivial - value_storage_nontrivial(value_storage_nontrivial &&o) noexcept(std::is_nothrow_move_constructible::value) // NOLINT - : _status(o._status) - { - if(this->_status.have_value()) - { - this->_status.set_have_value(false); - new(&_value) value_type(static_cast(o._value)); // NOLINT - _status = o._status; - } - } - value_storage_nontrivial(const value_storage_nontrivial &o) noexcept(std::is_nothrow_copy_constructible::value) - : _status(o._status) - { - if(this->_status.have_value()) - { - this->_status.set_have_value(false); - new(&_value) value_type(o._value); // NOLINT - _status = o._status; - } - } - // Special from-void constructor, constructs default T if void valued - explicit value_storage_nontrivial(const value_storage_trivial &o) noexcept(std::is_nothrow_default_constructible::value) - : _status(o._status) - { - if(this->_status.have_value()) - { - this->_status.set_have_value(false); - new(&_value) value_type; // NOLINT - _status = o._status; - } - } - explicit value_storage_nontrivial(status_bitfield_type status) - : _empty() - , _status(status) - { - } - template - explicit value_storage_nontrivial(in_place_type_t /*unused*/, - Args &&... args) noexcept(detail::is_nothrow_constructible) - : _value(static_cast(args)...) // NOLINT - , _status(status::have_value) - { - } - template - value_storage_nontrivial(in_place_type_t /*unused*/, std::initializer_list il, - Args &&... args) noexcept(detail::is_nothrow_constructible, Args...>) - : _value(il, static_cast(args)...) - , _status(status::have_value) - { - } - template - static constexpr bool enable_converting_constructor = !std::is_same, value_type>::value && detail::is_constructible; - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_nontrivial(const value_storage_nontrivial &o) noexcept(detail::is_nothrow_constructible) - : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, o._value) : value_storage_nontrivial()) - { - _status = o._status; - } - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_nontrivial(const value_storage_trivial &o) noexcept(detail::is_nothrow_constructible) - : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, o._value) : value_storage_nontrivial()) - { - _status = o._status; - } - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_nontrivial(value_storage_nontrivial &&o) noexcept(detail::is_nothrow_constructible) - : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, static_cast(o._value)) : - value_storage_nontrivial()) - { - _status = o._status; - } - BOOST_OUTCOME_TEMPLATE(class U) - BOOST_OUTCOME_TREQUIRES(BOOST_OUTCOME_TPRED(enable_converting_constructor)) - constexpr explicit value_storage_nontrivial(value_storage_trivial &&o) noexcept(detail::is_nothrow_constructible) - : value_storage_nontrivial(o._status.have_value() ? value_storage_nontrivial(in_place_type, static_cast(o._value)) : - value_storage_nontrivial()) - { - _status = o._status; - } - ~value_storage_nontrivial() noexcept(std::is_nothrow_destructible::value) - { - if(this->_status.have_value()) - { - this->_value.~value_type(); // NOLINT - this->_status.set_have_value(false); - } - } - constexpr void swap(value_storage_nontrivial &o) noexcept(detail::is_nothrow_swappable::value) - { - using std::swap; - if(!_status.have_value() && !o._status.have_value()) - { - swap(_status, o._status); - return; - } - if(_status.have_value() && o._status.have_value()) - { - struct _ - { - status_bitfield_type &a, &b; - bool all_good{false}; - ~_() - { - if(!all_good) - { - // We lost one of the values - a.set_have_lost_consistency(true); - b.set_have_lost_consistency(true); - } - } - } _{_status, o._status}; - strong_swap(_.all_good, _value, o._value); - swap(_status, o._status); - return; - } - // One must be empty and the other non-empty, so use move construction - if(_status.have_value()) - { - // Move construct me into other - new(&o._value) value_type(static_cast(_value)); // NOLINT - this->_value.~value_type(); // NOLINT - swap(_status, o._status); - } - else - { - // Move construct other into me - new(&_value) value_type(static_cast(o._value)); // NOLINT - o._value.~value_type(); // NOLINT - swap(_status, o._status); - } - } - }; - template struct value_storage_delete_copy_constructor : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_delete_copy_constructor() = default; - value_storage_delete_copy_constructor(const value_storage_delete_copy_constructor &) = delete; - value_storage_delete_copy_constructor(value_storage_delete_copy_constructor &&) = default; // NOLINT - }; - template struct value_storage_delete_copy_assignment : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_delete_copy_assignment() = default; - value_storage_delete_copy_assignment(const value_storage_delete_copy_assignment &) = default; - value_storage_delete_copy_assignment(value_storage_delete_copy_assignment &&) = default; // NOLINT - value_storage_delete_copy_assignment &operator=(const value_storage_delete_copy_assignment &o) = delete; - value_storage_delete_copy_assignment &operator=(value_storage_delete_copy_assignment &&o) = default; // NOLINT - }; - template struct value_storage_delete_move_assignment : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_delete_move_assignment() = default; - value_storage_delete_move_assignment(const value_storage_delete_move_assignment &) = default; - value_storage_delete_move_assignment(value_storage_delete_move_assignment &&) = default; // NOLINT - value_storage_delete_move_assignment &operator=(const value_storage_delete_move_assignment &o) = default; - value_storage_delete_move_assignment &operator=(value_storage_delete_move_assignment &&o) = delete; - }; - template struct value_storage_delete_move_constructor : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_delete_move_constructor() = default; - value_storage_delete_move_constructor(const value_storage_delete_move_constructor &) = default; - value_storage_delete_move_constructor(value_storage_delete_move_constructor &&) = delete; - }; - template struct value_storage_nontrivial_move_assignment : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_nontrivial_move_assignment() = default; - value_storage_nontrivial_move_assignment(const value_storage_nontrivial_move_assignment &) = default; - value_storage_nontrivial_move_assignment(value_storage_nontrivial_move_assignment &&) = default; // NOLINT - value_storage_nontrivial_move_assignment &operator=(const value_storage_nontrivial_move_assignment &o) = default; - value_storage_nontrivial_move_assignment & - operator=(value_storage_nontrivial_move_assignment &&o) noexcept(std::is_nothrow_move_assignable::value) // NOLINT - { - if(this->_status.have_value() && o._status.have_value()) - { - this->_value = static_cast(o._value); // NOLINT - } - else if(this->_status.have_value() && !o._status.have_value()) - { - this->_value.~value_type(); // NOLINT - } - else if(!this->_status.have_value() && o._status.have_value()) - { - new(&this->_value) value_type(static_cast(o._value)); // NOLINT - } - this->_status = o._status; - return *this; - } - }; - template struct value_storage_nontrivial_copy_assignment : Base // NOLINT - { - using Base::Base; - using value_type = typename Base::value_type; - value_storage_nontrivial_copy_assignment() = default; - value_storage_nontrivial_copy_assignment(const value_storage_nontrivial_copy_assignment &) = default; - value_storage_nontrivial_copy_assignment(value_storage_nontrivial_copy_assignment &&) = default; // NOLINT - value_storage_nontrivial_copy_assignment &operator=(value_storage_nontrivial_copy_assignment &&o) = default; // NOLINT - value_storage_nontrivial_copy_assignment & - operator=(const value_storage_nontrivial_copy_assignment &o) noexcept(std::is_nothrow_copy_assignable::value) - { - if(this->_status.have_value() && o._status.have_value()) - { - this->_value = o._value; // NOLINT - } - else if(this->_status.have_value() && !o._status.have_value()) - { - this->_value.~value_type(); // NOLINT - } - else if(!this->_status.have_value() && o._status.have_value()) - { - new(&this->_value) value_type(o._value); // NOLINT - } - this->_status = o._status; - return *this; - } - }; - - // We don't actually need all of std::is_trivial<>, std::is_trivially_copyable<> is sufficient - template - using value_storage_select_trivality = - std::conditional_t>::value, value_storage_trivial, value_storage_nontrivial>; - template - using value_storage_select_move_constructor = std::conditional_t>::value, value_storage_select_trivality, - value_storage_delete_move_constructor>>; - template - using value_storage_select_copy_constructor = std::conditional_t>::value, value_storage_select_move_constructor, - value_storage_delete_copy_constructor>>; - template - using value_storage_select_move_assignment = std::conditional_t< - std::is_trivially_move_assignable>::value, value_storage_select_copy_constructor, - std::conditional_t>::value, value_storage_nontrivial_move_assignment>, - value_storage_delete_copy_assignment>>>; - template - using value_storage_select_copy_assignment = std::conditional_t< - std::is_trivially_copy_assignable>::value, value_storage_select_move_assignment, - std::conditional_t>::value, value_storage_nontrivial_copy_assignment>, - value_storage_delete_copy_assignment>>>; - template using value_storage_select_impl = value_storage_select_copy_assignment; -#ifndef NDEBUG - // Check is trivial in all ways except default constructibility - // static_assert(std::is_trivial>::value, "value_storage_select_impl is not trivial!"); - // static_assert(std::is_trivially_default_constructible>::value, "value_storage_select_impl is not trivially default - // constructible!"); - static_assert(std::is_trivially_copyable>::value, "value_storage_select_impl is not trivially copyable!"); - static_assert(std::is_trivially_assignable, value_storage_select_impl>::value, - "value_storage_select_impl is not trivially assignable!"); - static_assert(std::is_trivially_destructible>::value, "value_storage_select_impl is not trivially destructible!"); - static_assert(std::is_trivially_copy_constructible>::value, - "value_storage_select_impl is not trivially copy constructible!"); - static_assert(std::is_trivially_move_constructible>::value, - "value_storage_select_impl is not trivially move constructible!"); - static_assert(std::is_trivially_copy_assignable>::value, "value_storage_select_impl is not trivially copy assignable!"); - static_assert(std::is_trivially_move_assignable>::value, "value_storage_select_impl is not trivially move assignable!"); - // Also check is standard layout - static_assert(std::is_standard_layout>::value, "value_storage_select_impl is not a standard layout type!"); -#endif -} // namespace detail - -BOOST_OUTCOME_V2_NAMESPACE_END - -#endif diff --git a/boost/outcome/experimental/coroutine_support.hpp b/boost/outcome/experimental/coroutine_support.hpp deleted file mode 100755 index 296b1fad75a8d6159717ad2ec2f16d2c901cad18..0000000000000000000000000000000000000000 --- a/boost/outcome/experimental/coroutine_support.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* Tells C++ coroutines about Outcome's result -(C) 2019-2020 Niall Douglas (12 commits) -File Created: Oct 2019 - - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -*/ - -#ifndef BOOST_OUTCOME_EXPERIMENTAL_COROUTINE_SUPPORT_HPP -#define BOOST_OUTCOME_EXPERIMENTAL_COROUTINE_SUPPORT_HPP - -#include "../config.hpp" - -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_BEGIN \ - BOOST_OUTCOME_V2_NAMESPACE_BEGIN namespace experimental \ - { \ - namespace awaitables \ - { -// -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_EXPORT_BEGIN \ - BOOST_OUTCOME_V2_NAMESPACE_EXPORT_BEGIN namespace experimental \ - { \ - namespace awaitables \ - { -// -#define BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_END \ - } \ - } \ - BOOST_OUTCOME_V2_NAMESPACE_END - -#ifndef BOOST_NO_EXCEPTIONS -#include "status-code/system_code_from_exception.hpp" -BOOST_OUTCOME_V2_NAMESPACE_BEGIN -namespace awaitables -{ - namespace detail - { - inline bool error_is_set(BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::system_code &sc) noexcept { return sc.failure(); } - inline BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::system_code error_from_exception(std::exception_ptr &&ep = std::current_exception(), BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::system_code not_matched = BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::generic_code(BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::errc::resource_unavailable_try_again)) noexcept - { - return BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::system_code_from_exception(static_cast(ep), static_cast(not_matched)); - } - } // namespace detail -} // namespace awaitables -BOOST_OUTCOME_V2_NAMESPACE_END -#endif - -#include "../detail/coroutine_support.ipp" - -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_BEGIN -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_EXPORT_BEGIN -#undef BOOST_OUTCOME_COROUTINE_SUPPORT_NAMESPACE_END - -#endif diff --git a/boost/outcome/experimental/status-code/config.hpp b/boost/outcome/experimental/status-code/config.hpp deleted file mode 100755 index a0a5bbc1d8d81aac5ab7f1180e33feb099f560dd..0000000000000000000000000000000000000000 --- a/boost/outcome/experimental/status-code/config.hpp +++ /dev/null @@ -1,327 +0,0 @@ -/* Proposed SG14 status_code -(C) 2018 - 2020 Niall Douglas (5 commits) -File Created: Feb 2018 - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License in the accompanying file -Licence.txt or at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -Distributed under the Boost Software License, Version 1.0. -(See accompanying file Licence.txt or copy at -http://www.boost.org/LICENSE_1_0.txt) -*/ - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_CONFIG_HPP -#define BOOST_OUTCOME_SYSTEM_ERROR2_CONFIG_HPP - -// < 0.1 each -#include -#include // for size_t -#include // for free - -// 0.22 -#include - -// 0.29 -#include - -// 0.28 (0.15 of which is exception_ptr) -#include // for std::exception -// includes , includes -#include - -// 0.01 -#include - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 -#if defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) || __cplusplus >= 201400 || _MSC_VER >= 1910 /* VS2017 */ -//! Defined to be `constexpr` when on C++ 14 or better compilers. Usually automatic, can be overriden. -#define BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 constexpr -#else -#define BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 -#endif -#endif - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN -#if defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) || (_HAS_CXX17 && _MSC_VER >= 1911 /* VS2017.3 */) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN [[noreturn]] -#endif -#endif -#if !defined(BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN) -#ifdef __has_cpp_attribute -#if __has_cpp_attribute(noreturn) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN [[noreturn]] -#endif -#endif -#endif -#if !defined(BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN) -#if defined(_MSC_VER) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN __declspec(noreturn) -#elif defined(__GNUC__) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN __attribute__((__noreturn__)) -#else -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN -#endif -#endif -// GCCs before 7 don't grok [[noreturn]] virtual functions, and warn annoyingly -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 7 -#undef BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN -#define BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN -#endif - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD -#if defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) || (_HAS_CXX17 && _MSC_VER >= 1911 /* VS2017.3 */) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD [[nodiscard]] -#endif -#endif -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD -#ifdef __has_cpp_attribute -#if __has_cpp_attribute(nodiscard) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD [[nodiscard]] -#endif -#elif defined(__clang__) -#define BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD __attribute__((warn_unused_result)) -#elif defined(_MSC_VER) -// _Must_inspect_result_ expands into this -#define BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD \ - __declspec("SAL_name" \ - "(" \ - "\"_Must_inspect_result_\"" \ - "," \ - "\"\"" \ - "," \ - "\"2\"" \ - ")") __declspec("SAL_begin") __declspec("SAL_post") __declspec("SAL_mustInspect") __declspec("SAL_post") __declspec("SAL_checkReturn") __declspec("SAL_end") -#endif -#endif -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD -#define BOOST_OUTCOME_SYSTEM_ERROR2_NODISCARD -#endif - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_TRIVIAL_ABI -#if defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) || (__clang_major__ >= 7 && !defined(__APPLE__)) -//! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden. -#define BOOST_OUTCOME_SYSTEM_ERROR2_TRIVIAL_ABI [[clang::trivial_abi]] -#else -#define BOOST_OUTCOME_SYSTEM_ERROR2_TRIVIAL_ABI -#endif -#endif - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE -//! The system_error2 namespace name. -#define BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE system_error2 -//! Begins the system_error2 namespace. -#define BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN \ - namespace system_error2 \ - { -//! Ends the system_error2 namespace. -#define BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END } -#endif - -//! Namespace for the library -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN - -//! Namespace for user specialised traits -namespace traits -{ - /*! Specialise to true if you guarantee that a type is move bitcopying (i.e. - its move constructor equals copying bits from old to new, old is left in a - default constructed state, and calling the destructor on a default constructed - instance is trivial). All trivially copyable types are move bitcopying by - definition, and that is the unspecialised implementation. - */ - template struct is_move_bitcopying - { - static constexpr bool value = std::is_trivially_copyable::value; - }; -} // namespace traits - -namespace detail -{ -#if __cplusplus >= 201400 || _MSC_VER >= 1910 /* VS2017 */ - inline constexpr size_t cstrlen(const char *str) - { - const char *end = nullptr; - for(end = str; *end != 0; ++end) // NOLINT - ; - return end - str; - } -#else - inline constexpr size_t cstrlen_(const char *str, size_t acc) - { - return (str[0] == 0) ? acc : cstrlen_(str + 1, acc + 1); - } - inline constexpr size_t cstrlen(const char *str) - { - return cstrlen_(str, 0); - } -#endif - - /* A partially compliant implementation of C++20's std::bit_cast function contributed - by Jesse Towner. TODO FIXME Replace with C++ 20 bit_cast when available. - - Our bit_cast is only guaranteed to be constexpr when both the input and output - arguments are either integrals or enums. However, this covers most use cases - since the vast majority of status_codes have an underlying type that is either - an integral or enum. We still attempt a constexpr union-based type pun for non-array - input types, which some compilers accept. For array inputs, we fall back to - non-constexpr memmove. - */ - - template using is_integral_or_enum = std::integral_constant::value || std::is_enum::value>; - - template using is_static_castable = std::integral_constant::value && is_integral_or_enum::value>; - - template using is_union_castable = std::integral_constant::value && !std::is_array::value && !std::is_array::value>; - - template using is_bit_castable = std::integral_constant::value && traits::is_move_bitcopying::value>; - - template union bit_cast_union { - From source; - To target; - }; - - template ::value // - && is_static_castable::value // - && !is_union_castable::value, // - bool>::type = true> // - constexpr To bit_cast(const From &from) noexcept - { - return static_cast(from); - } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif - template ::value // - && !is_static_castable::value // - && is_union_castable::value, // - bool>::type = true> // - constexpr To bit_cast(const From &from) noexcept - { - return bit_cast_union{from}.target; - } -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif - - template ::value // - && !is_static_castable::value // - && !is_union_castable::value, // - bool>::type = true> // - To bit_cast(const From &from) noexcept - { - bit_cast_union ret; - memmove(&ret.source, &from, sizeof(ret.source)); - return ret.target; - } - - /* erasure_cast performs a bit_cast with additional rules to handle types - of differing sizes. For integral & enum types, it may perform a narrowing - or widing conversion with static_cast if necessary, before doing the final - conversion with bit_cast. When casting to or from non-integral, non-enum - types it may insert the value into another object with extra padding bytes - to satisfy bit_cast's preconditions that both types have the same size. */ - - template using is_erasure_castable = std::integral_constant::value && traits::is_move_bitcopying::value>; - - template ::value> struct identity_or_underlying_type - { - using type = T; - }; - template struct identity_or_underlying_type - { - using type = typename std::underlying_type::type; - }; - - template - using erasure_integer_type = typename std::conditional::type>::value, typename std::make_signed::type>::type, typename std::make_unsigned::type>::type>::type; - - template struct padded_erasure_object - { - static_assert(traits::is_move_bitcopying::value, "ErasedType must be TriviallyCopyable or MoveBitcopying"); - static_assert(alignof(ErasedType) <= sizeof(ErasedType), "ErasedType must not be over-aligned"); - ErasedType value; - char padding[N]; - constexpr explicit padded_erasure_object(const ErasedType &v) noexcept - : value(v) - , padding{} - { - } - }; - - template ::value && (sizeof(To) == sizeof(From)), bool>::type = true> constexpr To erasure_cast(const From &from) noexcept { return bit_cast(from); } - - template ::value && is_static_castable::value && (sizeof(To) < sizeof(From)), bool>::type = true> constexpr To erasure_cast(const From &from) noexcept { return static_cast(bit_cast>(from)); } - - template ::value && is_static_castable::value && (sizeof(To) > sizeof(From)), bool>::type = true> constexpr To erasure_cast(const From &from) noexcept { return bit_cast(static_cast>(from)); } - - template ::value && !is_static_castable::value && (sizeof(To) < sizeof(From)), bool>::type = true> constexpr To erasure_cast(const From &from) noexcept - { - return bit_cast>(from).value; - } - - template ::value && !is_static_castable::value && (sizeof(To) > sizeof(From)), bool>::type = true> constexpr To erasure_cast(const From &from) noexcept - { - return bit_cast(padded_erasure_object{from}); - } -} // namespace detail -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_FATAL -#ifdef BOOST_OUTCOME_SYSTEM_ERROR2_NOT_POSIX -#error If BOOST_OUTCOME_SYSTEM_ERROR2_NOT_POSIX is defined, you must define your own BOOST_OUTCOME_SYSTEM_ERROR2_FATAL implementation! -#endif -#include // for abort -#ifdef __APPLE__ -#include // for write -#endif - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN -namespace detail -{ - namespace avoid_stdio_include - { -#if !defined(__APPLE__) && !defined(_MSC_VER) - extern "C" ptrdiff_t write(int, const void *, size_t); -#elif defined(_MSC_VER) - extern ptrdiff_t write(int, const void *, size_t); -#if defined(_WIN64) -#pragma comment(linker, "/alternatename:?write@avoid_stdio_include@detail@system_error2@@YA_JHPEBX_K@Z=write") -#else -#pragma comment(linker, "/alternatename:?write@avoid_stdio_include@detail@system_error2@@YAHHPBXI@Z=_write") -#endif -#endif - } // namespace avoid_stdio_include - inline void do_fatal_exit(const char *msg) - { - using namespace avoid_stdio_include; - write(2 /*stderr*/, msg, cstrlen(msg)); - write(2 /*stderr*/, "\n", 1); - abort(); - } -} // namespace detail -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END -//! Prints msg to stderr, and calls `std::terminate()`. Can be overriden via predefinition. -#define BOOST_OUTCOME_SYSTEM_ERROR2_FATAL(msg) ::BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE::detail::do_fatal_exit(msg) -#endif - -#endif diff --git a/boost/outcome/experimental/status-code/generic_code.hpp b/boost/outcome/experimental/status-code/generic_code.hpp deleted file mode 100755 index efd1283a52746abe4d54ae9f71f52f2c02266109..0000000000000000000000000000000000000000 --- a/boost/outcome/experimental/status-code/generic_code.hpp +++ /dev/null @@ -1,479 +0,0 @@ -/* Proposed SG14 status_code -(C) 2018 - 2020 Niall Douglas (5 commits) -File Created: Feb 2018 - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License in the accompanying file -Licence.txt or at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -Distributed under the Boost Software License, Version 1.0. -(See accompanying file Licence.txt or copy at -http://www.boost.org/LICENSE_1_0.txt) -*/ - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_GENERIC_CODE_HPP -#define BOOST_OUTCOME_SYSTEM_ERROR2_GENERIC_CODE_HPP - -#include "status_error.hpp" - -#include // for error constants - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN - -//! The generic error coding (POSIX) -enum class errc : int -{ - success = 0, - unknown = -1, - - address_family_not_supported = EAFNOSUPPORT, - address_in_use = EADDRINUSE, - address_not_available = EADDRNOTAVAIL, - already_connected = EISCONN, - argument_list_too_long = E2BIG, - argument_out_of_domain = EDOM, - bad_address = EFAULT, - bad_file_descriptor = EBADF, - bad_message = EBADMSG, - broken_pipe = EPIPE, - connection_aborted = ECONNABORTED, - connection_already_in_progress = EALREADY, - connection_refused = ECONNREFUSED, - connection_reset = ECONNRESET, - cross_device_link = EXDEV, - destination_address_required = EDESTADDRREQ, - device_or_resource_busy = EBUSY, - directory_not_empty = ENOTEMPTY, - executable_format_error = ENOEXEC, - file_exists = EEXIST, - file_too_large = EFBIG, - filename_too_long = ENAMETOOLONG, - function_not_supported = ENOSYS, - host_unreachable = EHOSTUNREACH, - identifier_removed = EIDRM, - illegal_byte_sequence = EILSEQ, - inappropriate_io_control_operation = ENOTTY, - interrupted = EINTR, - invalid_argument = EINVAL, - invalid_seek = ESPIPE, - io_error = EIO, - is_a_directory = EISDIR, - message_size = EMSGSIZE, - network_down = ENETDOWN, - network_reset = ENETRESET, - network_unreachable = ENETUNREACH, - no_buffer_space = ENOBUFS, - no_child_process = ECHILD, - no_link = ENOLINK, - no_lock_available = ENOLCK, - no_message = ENOMSG, - no_protocol_option = ENOPROTOOPT, - no_space_on_device = ENOSPC, - no_stream_resources = ENOSR, - no_such_device_or_address = ENXIO, - no_such_device = ENODEV, - no_such_file_or_directory = ENOENT, - no_such_process = ESRCH, - not_a_directory = ENOTDIR, - not_a_socket = ENOTSOCK, - not_a_stream = ENOSTR, - not_connected = ENOTCONN, - not_enough_memory = ENOMEM, - not_supported = ENOTSUP, - operation_canceled = ECANCELED, - operation_in_progress = EINPROGRESS, - operation_not_permitted = EPERM, - operation_not_supported = EOPNOTSUPP, - operation_would_block = EWOULDBLOCK, - owner_dead = EOWNERDEAD, - permission_denied = EACCES, - protocol_error = EPROTO, - protocol_not_supported = EPROTONOSUPPORT, - read_only_file_system = EROFS, - resource_deadlock_would_occur = EDEADLK, - resource_unavailable_try_again = EAGAIN, - result_out_of_range = ERANGE, - state_not_recoverable = ENOTRECOVERABLE, - stream_timeout = ETIME, - text_file_busy = ETXTBSY, - timed_out = ETIMEDOUT, - too_many_files_open_in_system = ENFILE, - too_many_files_open = EMFILE, - too_many_links = EMLINK, - too_many_symbolic_link_levels = ELOOP, - value_too_large = EOVERFLOW, - wrong_protocol_type = EPROTOTYPE -}; - -namespace detail -{ - BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 inline const char *generic_code_message(errc code) noexcept - { - switch(code) - { - case errc::success: - return "Success"; - case errc::address_family_not_supported: - return "Address family not supported by protocol"; - case errc::address_in_use: - return "Address already in use"; - case errc::address_not_available: - return "Cannot assign requested address"; - case errc::already_connected: - return "Transport endpoint is already connected"; - case errc::argument_list_too_long: - return "Argument list too long"; - case errc::argument_out_of_domain: - return "Numerical argument out of domain"; - case errc::bad_address: - return "Bad address"; - case errc::bad_file_descriptor: - return "Bad file descriptor"; - case errc::bad_message: - return "Bad message"; - case errc::broken_pipe: - return "Broken pipe"; - case errc::connection_aborted: - return "Software caused connection abort"; - case errc::connection_already_in_progress: - return "Operation already in progress"; - case errc::connection_refused: - return "Connection refused"; - case errc::connection_reset: - return "Connection reset by peer"; - case errc::cross_device_link: - return "Invalid cross-device link"; - case errc::destination_address_required: - return "Destination address required"; - case errc::device_or_resource_busy: - return "Device or resource busy"; - case errc::directory_not_empty: - return "Directory not empty"; - case errc::executable_format_error: - return "Exec format error"; - case errc::file_exists: - return "File exists"; - case errc::file_too_large: - return "File too large"; - case errc::filename_too_long: - return "File name too long"; - case errc::function_not_supported: - return "Function not implemented"; - case errc::host_unreachable: - return "No route to host"; - case errc::identifier_removed: - return "Identifier removed"; - case errc::illegal_byte_sequence: - return "Invalid or incomplete multibyte or wide character"; - case errc::inappropriate_io_control_operation: - return "Inappropriate ioctl for device"; - case errc::interrupted: - return "Interrupted system call"; - case errc::invalid_argument: - return "Invalid argument"; - case errc::invalid_seek: - return "Illegal seek"; - case errc::io_error: - return "Input/output error"; - case errc::is_a_directory: - return "Is a directory"; - case errc::message_size: - return "Message too long"; - case errc::network_down: - return "Network is down"; - case errc::network_reset: - return "Network dropped connection on reset"; - case errc::network_unreachable: - return "Network is unreachable"; - case errc::no_buffer_space: - return "No buffer space available"; - case errc::no_child_process: - return "No child processes"; - case errc::no_link: - return "Link has been severed"; - case errc::no_lock_available: - return "No locks available"; - case errc::no_message: - return "No message of desired type"; - case errc::no_protocol_option: - return "Protocol not available"; - case errc::no_space_on_device: - return "No space left on device"; - case errc::no_stream_resources: - return "Out of streams resources"; - case errc::no_such_device_or_address: - return "No such device or address"; - case errc::no_such_device: - return "No such device"; - case errc::no_such_file_or_directory: - return "No such file or directory"; - case errc::no_such_process: - return "No such process"; - case errc::not_a_directory: - return "Not a directory"; - case errc::not_a_socket: - return "Socket operation on non-socket"; - case errc::not_a_stream: - return "Device not a stream"; - case errc::not_connected: - return "Transport endpoint is not connected"; - case errc::not_enough_memory: - return "Cannot allocate memory"; -#if ENOTSUP != EOPNOTSUPP - case errc::not_supported: - return "Operation not supported"; -#endif - case errc::operation_canceled: - return "Operation canceled"; - case errc::operation_in_progress: - return "Operation now in progress"; - case errc::operation_not_permitted: - return "Operation not permitted"; - case errc::operation_not_supported: - return "Operation not supported"; -#if EAGAIN != EWOULDBLOCK - case errc::operation_would_block: - return "Resource temporarily unavailable"; -#endif - case errc::owner_dead: - return "Owner died"; - case errc::permission_denied: - return "Permission denied"; - case errc::protocol_error: - return "Protocol error"; - case errc::protocol_not_supported: - return "Protocol not supported"; - case errc::read_only_file_system: - return "Read-only file system"; - case errc::resource_deadlock_would_occur: - return "Resource deadlock avoided"; - case errc::resource_unavailable_try_again: - return "Resource temporarily unavailable"; - case errc::result_out_of_range: - return "Numerical result out of range"; - case errc::state_not_recoverable: - return "State not recoverable"; - case errc::stream_timeout: - return "Timer expired"; - case errc::text_file_busy: - return "Text file busy"; - case errc::timed_out: - return "Connection timed out"; - case errc::too_many_files_open_in_system: - return "Too many open files in system"; - case errc::too_many_files_open: - return "Too many open files"; - case errc::too_many_links: - return "Too many links"; - case errc::too_many_symbolic_link_levels: - return "Too many levels of symbolic links"; - case errc::value_too_large: - return "Value too large for defined data type"; - case errc::wrong_protocol_type: - return "Protocol wrong type for socket"; - default: - return "unknown"; - } - } -} // namespace detail - -/*! The implementation of the domain for generic status codes, those mapped by `errc` (POSIX). - */ -class _generic_code_domain : public status_code_domain -{ - template friend class status_code; - template friend class detail::indirecting_domain; - using _base = status_code_domain; - -public: - //! The value type of the generic code, which is an `errc` as per POSIX. - using value_type = errc; - using string_ref = _base::string_ref; - -public: - //! Default constructor - constexpr explicit _generic_code_domain(typename _base::unique_id_type id = 0x746d6354f4f733e9) noexcept - : _base(id) - { - } - _generic_code_domain(const _generic_code_domain &) = default; - _generic_code_domain(_generic_code_domain &&) = default; - _generic_code_domain &operator=(const _generic_code_domain &) = default; - _generic_code_domain &operator=(_generic_code_domain &&) = default; - ~_generic_code_domain() = default; - - //! Constexpr singleton getter. Returns the constexpr generic_code_domain variable. - static inline constexpr const _generic_code_domain &get(); - - virtual _base::string_ref name() const noexcept override { return string_ref("generic domain"); } // NOLINT -protected: - virtual bool _do_failure(const status_code &code) const noexcept override // NOLINT - { - assert(code.domain() == *this); // NOLINT - return static_cast(code).value() != errc::success; // NOLINT - } - virtual bool _do_equivalent(const status_code &code1, const status_code &code2) const noexcept override // NOLINT - { - assert(code1.domain() == *this); // NOLINT - const auto &c1 = static_cast(code1); // NOLINT - if(code2.domain() == *this) - { - const auto &c2 = static_cast(code2); // NOLINT - return c1.value() == c2.value(); - } - return false; - } - virtual generic_code _generic_code(const status_code &code) const noexcept override // NOLINT - { - assert(code.domain() == *this); // NOLINT - return static_cast(code); // NOLINT - } - virtual _base::string_ref _do_message(const status_code &code) const noexcept override // NOLINT - { - assert(code.domain() == *this); // NOLINT - const auto &c = static_cast(code); // NOLINT - return string_ref(detail::generic_code_message(c.value())); - } -#if defined(_CPPUNWIND) || defined(__EXCEPTIONS) || defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) - BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN virtual void _do_throw_exception(const status_code &code) const override // NOLINT - { - assert(code.domain() == *this); // NOLINT - const auto &c = static_cast(code); // NOLINT - throw status_error<_generic_code_domain>(c); - } -#endif -}; -//! A specialisation of `status_error` for the generic code domain. -using generic_error = status_error<_generic_code_domain>; -//! A constexpr source variable for the generic code domain, which is that of `errc` (POSIX). Returned by `_generic_code_domain::get()`. -constexpr _generic_code_domain generic_code_domain; -inline constexpr const _generic_code_domain &_generic_code_domain::get() -{ - return generic_code_domain; -} -// Enable implicit construction of generic_code from errc -BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 inline generic_code make_status_code(errc c) noexcept -{ - return generic_code(in_place, c); -} - - -/*************************************************************************************************************/ - - -template inline bool status_code::equivalent(const status_code &o) const noexcept -{ - if(_domain && o._domain) - { - if(_domain->_do_equivalent(*this, o)) - { - return true; - } - if(o._domain->_do_equivalent(o, *this)) - { - return true; - } - generic_code c1 = o._domain->_generic_code(o); - if(c1.value() != errc::unknown && _domain->_do_equivalent(*this, c1)) - { - return true; - } - generic_code c2 = _domain->_generic_code(*this); - if(c2.value() != errc::unknown && o._domain->_do_equivalent(o, c2)) - { - return true; - } - } - // If we are both empty, we are equivalent, otherwise not equivalent - return (!_domain && !o._domain); -} -//! True if the status code's are semantically equal via `equivalent()`. -template inline bool operator==(const status_code &a, const status_code &b) noexcept -{ - return a.equivalent(b); -} -//! True if the status code's are not semantically equal via `equivalent()`. -template inline bool operator!=(const status_code &a, const status_code &b) noexcept -{ - return !a.equivalent(b); -} -//! True if the status code's are semantically equal via `equivalent()` to `make_status_code(T)`. -template ::type, // Safe ADL lookup of make_status_code(), returns void if not found - typename std::enable_if::value, bool>::type = true> // ADL makes a status code -inline bool operator==(const status_code &a, const T &b) -{ - return a.equivalent(make_status_code(b)); -} -//! True if the status code's are semantically equal via `equivalent()` to `make_status_code(T)`. -template ::type, // Safe ADL lookup of make_status_code(), returns void if not found - typename std::enable_if::value, bool>::type = true> // ADL makes a status code -inline bool operator==(const T &a, const status_code &b) -{ - return b.equivalent(make_status_code(a)); -} -//! True if the status code's are not semantically equal via `equivalent()` to `make_status_code(T)`. -template ::type, // Safe ADL lookup of make_status_code(), returns void if not found - typename std::enable_if::value, bool>::type = true> // ADL makes a status code -inline bool operator!=(const status_code &a, const T &b) -{ - return !a.equivalent(make_status_code(b)); -} -//! True if the status code's are semantically equal via `equivalent()` to `make_status_code(T)`. -template ::type, // Safe ADL lookup of make_status_code(), returns void if not found - typename std::enable_if::value, bool>::type = true> // ADL makes a status code -inline bool operator!=(const T &a, const status_code &b) -{ - return !b.equivalent(make_status_code(a)); -} -//! True if the status code's are semantically equal via `equivalent()` to `quick_status_code_from_enum::code_type(b)`. -template ::code_type // Enumeration has been activated - > -inline bool operator==(const status_code &a, const T &b) -{ - return a.equivalent(QuickStatusCodeType(b)); -} -//! True if the status code's are semantically equal via `equivalent()` to `quick_status_code_from_enum::code_type(a)`. -template ::code_type // Enumeration has been activated - > -inline bool operator==(const T &a, const status_code &b) -{ - return b.equivalent(QuickStatusCodeType(a)); -} -//! True if the status code's are not semantically equal via `equivalent()` to `quick_status_code_from_enum::code_type(b)`. -template ::code_type // Enumeration has been activated - > -inline bool operator!=(const status_code &a, const T &b) -{ - return !a.equivalent(QuickStatusCodeType(b)); -} -//! True if the status code's are not semantically equal via `equivalent()` to `quick_status_code_from_enum::code_type(a)`. -template ::code_type // Enumeration has been activated - > -inline bool operator!=(const T &a, const status_code &b) -{ - return !b.equivalent(QuickStatusCodeType(a)); -} - - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END - -#endif diff --git a/boost/outcome/experimental/status-code/quick_status_code_from_enum.hpp b/boost/outcome/experimental/status-code/quick_status_code_from_enum.hpp deleted file mode 100644 index 8d9ccd0661da285c62a90bf6355e71c01ba2e86c..0000000000000000000000000000000000000000 --- a/boost/outcome/experimental/status-code/quick_status_code_from_enum.hpp +++ /dev/null @@ -1,210 +0,0 @@ -/* Proposed SG14 status_code -(C) 2018 - 2020 Niall Douglas (5 commits) -File Created: May 2020 - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License in the accompanying file -Licence.txt or at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -Distributed under the Boost Software License, Version 1.0. -(See accompanying file Licence.txt or copy at -http://www.boost.org/LICENSE_1_0.txt) -*/ - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_QUICK_STATUS_CODE_FROM_ENUM_HPP -#define BOOST_OUTCOME_SYSTEM_ERROR2_QUICK_STATUS_CODE_FROM_ENUM_HPP - -#include "generic_code.hpp" - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN - -template class _quick_status_code_from_enum_domain; -//! A status code wrapping `Enum` generated from `quick_status_code_from_enum`. -template using quick_status_code_from_enum_code = status_code<_quick_status_code_from_enum_domain>; - -//! Defaults for an implementation of `quick_status_code_from_enum` -template struct quick_status_code_from_enum_defaults -{ - //! The type of the resulting code - using code_type = quick_status_code_from_enum_code; - //! Used within `quick_status_code_from_enum` to define a mapping of enumeration value with its status code - struct mapping - { - //! The enumeration type - using enumeration_type = Enum; - - //! The value being mapped - const Enum value; - //! A string representation for this enumeration value - const char *message; - //! A list of `errc` equivalents for this enumeration value - const std::initializer_list code_mappings; - }; - //! Used within `quick_status_code_from_enum` to define mixins for the status code wrapping `Enum` - template struct mixin : Base - { - using Base::Base; - }; -}; - -/*! The implementation of the domain for status codes wrapping `Enum` generated from `quick_status_code_from_enum`. - */ -template class _quick_status_code_from_enum_domain : public status_code_domain -{ - template friend class status_code; - template friend class detail::indirecting_domain; - using _base = status_code_domain; - using _src = quick_status_code_from_enum; - -public: - //! The value type of the quick status code from enum - using value_type = Enum; - using _base::string_ref; - - constexpr _quick_status_code_from_enum_domain() - : status_code_domain(_src::domain_uuid, _uuid_size()) - { - } - _quick_status_code_from_enum_domain(const _quick_status_code_from_enum_domain &) = default; - _quick_status_code_from_enum_domain(_quick_status_code_from_enum_domain &&) = default; - _quick_status_code_from_enum_domain &operator=(const _quick_status_code_from_enum_domain &) = default; - _quick_status_code_from_enum_domain &operator=(_quick_status_code_from_enum_domain &&) = default; - ~_quick_status_code_from_enum_domain() = default; - -#if __cplusplus < 201402L && !defined(_MSC_VER) - static inline const _quick_status_code_from_enum_domain &get() - { - static _quick_status_code_from_enum_domain v; - return v; - } -#else - static inline constexpr const _quick_status_code_from_enum_domain &get(); -#endif - - virtual string_ref name() const noexcept override { return string_ref(_src::domain_name); } - -protected: - // Not sure if a hash table is worth it here, most enumerations won't be long enough to be worth it - // Also, until C++ 20's consteval, the hash table would get emitted into the binary, bloating it - static BOOST_OUTCOME_SYSTEM_ERROR2_CONSTEXPR14 const typename _src::mapping *_find_mapping(value_type v) noexcept - { - for(const auto &i : _src::value_mappings()) - { - if(i.value == v) - { - return &i; - } - } - return nullptr; - } - - virtual bool _do_failure(const status_code &code) const noexcept override - { - assert(code.domain() == *this); // NOLINT - // If `errc::success` is in the generic code mapping, it is not a failure - const auto *mapping = _find_mapping(static_cast &>(code).value()); - assert(mapping != nullptr); - if(mapping != nullptr) - { - for(errc ec : mapping->code_mappings) - { - if(ec == errc::success) - { - return false; - } - } - } - return true; - } - virtual bool _do_equivalent(const status_code &code1, const status_code &code2) const noexcept override - { - assert(code1.domain() == *this); // NOLINT - const auto &c1 = static_cast &>(code1); // NOLINT - if(code2.domain() == *this) - { - const auto &c2 = static_cast &>(code2); // NOLINT - return c1.value() == c2.value(); - } - if(code2.domain() == generic_code_domain) - { - const auto &c2 = static_cast(code2); // NOLINT - const auto *mapping = _find_mapping(c1.value()); - assert(mapping != nullptr); - if(mapping != nullptr) - { - for(errc ec : mapping->code_mappings) - { - if(ec == c2.value()) - { - return true; - } - } - } - } - return false; - } - virtual generic_code _generic_code(const status_code &code) const noexcept override - { - assert(code.domain() == *this); // NOLINT - const auto *mapping = _find_mapping(static_cast &>(code).value()); - assert(mapping != nullptr); - if(mapping != nullptr) - { - if(mapping->code_mappings.size() > 0) - { - return *mapping->code_mappings.begin(); - } - } - return errc::unknown; - } - virtual string_ref _do_message(const status_code &code) const noexcept override - { - assert(code.domain() == *this); // NOLINT - const auto *mapping = _find_mapping(static_cast &>(code).value()); - assert(mapping != nullptr); - if(mapping != nullptr) - { - return string_ref(mapping->message); - } - return string_ref("unknown"); - } -#if defined(_CPPUNWIND) || defined(__EXCEPTIONS) || defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) - BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN virtual void _do_throw_exception(const status_code &code) const override - { - assert(code.domain() == *this); // NOLINT - const auto &c = static_cast &>(code); // NOLINT - throw status_error<_quick_status_code_from_enum_domain>(c); - } -#endif -}; - -#if __cplusplus >= 201402L || defined(_MSC_VER) -template constexpr _quick_status_code_from_enum_domain quick_status_code_from_enum_domain = {}; -template inline constexpr const _quick_status_code_from_enum_domain &_quick_status_code_from_enum_domain::get() -{ - return quick_status_code_from_enum_domain; -} -#endif - -namespace mixins -{ - template struct mixin> : public quick_status_code_from_enum::template mixin - { - using quick_status_code_from_enum::template mixin::mixin; - }; -} // namespace mixins - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END - -#endif diff --git a/boost/outcome/experimental/status-code/status_code.hpp b/boost/outcome/experimental/status-code/status_code.hpp deleted file mode 100755 index 03a56c2171c00737895065e79b9efc94a6f3d807..0000000000000000000000000000000000000000 --- a/boost/outcome/experimental/status-code/status_code.hpp +++ /dev/null @@ -1,568 +0,0 @@ -/* Proposed SG14 status_code -(C) 2018 - 2019 Niall Douglas (5 commits) -File Created: Feb 2018 - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License in the accompanying file -Licence.txt or at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -Distributed under the Boost Software License, Version 1.0. -(See accompanying file Licence.txt or copy at -http://www.boost.org/LICENSE_1_0.txt) -*/ - -#ifndef BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_CODE_HPP -#define BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_CODE_HPP - -#include "status_code_domain.hpp" - -#if(__cplusplus >= 201700 || _HAS_CXX17) && !defined(BOOST_OUTCOME_SYSTEM_ERROR2_DISABLE_STD_IN_PLACE) -// 0.26 -#include // for in_place - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN -using in_place_t = std::in_place_t; -using std::in_place; -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END - -#else - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN -//! Aliases `std::in_place_t` if on C++ 17 or later, else defined locally. -struct in_place_t -{ - explicit in_place_t() = default; -}; -//! Aliases `std::in_place` if on C++ 17 or later, else defined locally. -constexpr in_place_t in_place{}; -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END -#endif - -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN - -//! Namespace for user injected mixins -namespace mixins -{ - template struct mixin : public Base - { - using Base::Base; - }; -} // namespace mixins - -/*! A tag for an erased value type for `status_code`. -Available only if `ErasedType` satisfies `traits::is_move_bitcopying::value`. -*/ -template ::value, bool>::type = true> -struct erased -{ - using value_type = ErasedType; -}; - -/*! Specialise this template to quickly wrap a third party enumeration into a -custom status code domain. - -Use like this: - -```c++ -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN -template <> struct quick_status_code_from_enum : quick_status_code_from_enum_defaults -{ - // Text name of the enum - static constexpr const auto domain_name = "Another Code"; - // Unique UUID for the enum. PLEASE use https://www.random.org/cgi-bin/randbyte?nbytes=16&format=h - static constexpr const auto domain_uuid = "{be201f65-3962-dd0e-1266-a72e63776a42}"; - // Map of each enum value to its text string, and list of semantically equivalent errc's - static const std::initializer_list &value_mappings() - { - static const std::initializer_list> v = { - // Format is: { enum value, "string representation", { list of errc mappings ... } } - {AnotherCode::success1, "Success 1", {errc::success}}, // - {AnotherCode::goaway, "Go away", {errc::permission_denied}}, // - {AnotherCode::success2, "Success 2", {errc::success}}, // - {AnotherCode::error2, "Error 2", {}}, // - }; - return v; - } - // Completely optional definition of mixin for the status code synthesised from `Enum`. It can be omitted. - template struct mixin : Base - { - using Base::Base; - constexpr int custom_method() const { return 42; } - }; -}; -BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END -``` - -Note that if the `errc` mapping contains `errc::success`, then -the enumeration value is considered to be a successful value. -Otherwise it is considered to be a failure value. - -The first value in the `errc` mapping is the one chosen as the -`generic_code` conversion. Other values are used during equivalence -comparisons. -*/ -template struct quick_status_code_from_enum; - -namespace detail -{ - template struct is_status_code - { - static constexpr bool value = false; - }; - template struct is_status_code> - { - static constexpr bool value = true; - }; - template struct is_erased_status_code - { - static constexpr bool value = false; - }; - template struct is_erased_status_code>> - { - static constexpr bool value = true; - }; - - // From http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4436.pdf - namespace impl - { - template struct make_void - { - using type = void; - }; - template using void_t = typename make_void::type; - template struct types - { - using type = types; - }; - template