?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/core.tar
???????
lightweight_test_trait.hpp 0000644 00000007605 15125235435 0012053 0 ustar 00 #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP #define BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif // boost/core/lightweight_test_trait.hpp // // BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME // // Copyright 2014 Peter Dimov // // Copyright 2019 Glen Joseph Fernandes // (glenjofe@gmail.com) // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include <boost/core/lightweight_test.hpp> #include <boost/core/typeinfo.hpp> #include <boost/core/is_same.hpp> #include <boost/config.hpp> namespace boost { namespace detail { template<class, int = 0> struct test_print { }; template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>) { return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T)); } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>) { return o << test_print<T, 2>(); } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>) { return o << test_print<T, 2>() << " const"; } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>) { return o << test_print<T, 2>() << " volatile"; } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>) { return o << test_print<T, 2>() << " const volatile"; } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>) { return o << test_print<T, 1>(); } template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>) { return o << test_print<T, 1>() << " &"; } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>) { return o << test_print<T, 1>() << " &&"; } #endif template< class T > inline void test_trait_impl( char const * trait, void (*)( T ), bool expected, char const * file, int line, char const * function ) { if( T::value == expected ) { test_results(); } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): predicate '" << trait << "' [" << boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]" << " test failed in function '" << function << "' (should have been " << ( expected? "true": "false" ) << ")" << std::endl; ++test_results().errors(); } } template<class T> inline bool test_trait_same_impl_( T ) { return T::value; } template<class T1, class T2> inline void test_trait_same_impl( char const * types, boost::core::is_same<T1, T2> same, char const * file, int line, char const * function ) { if( test_trait_same_impl_( same ) ) { test_results(); } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test 'is_same<" << types << ">'" << " failed in function '" << function << "' ('" << test_print<T1>() << "' != '" << test_print<T2>() << "')" << std::endl; ++test_results().errors(); } } } // namespace detail } // namespace boost #define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) #define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) #if defined(__GNUC__) // ignoring -Wvariadic-macros with #pragma doesn't work under GCC # pragma GCC system_header #endif #define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) #endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP typeinfo.hpp 0000644 00000006117 15125235435 0007124 0 ustar 00 #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED #define BOOST_CORE_TYPEINFO_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // core::typeinfo, BOOST_CORE_TYPEID // // Copyright 2007, 2014 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/config.hpp> #if defined( BOOST_NO_TYPEID ) #include <boost/current_function.hpp> #include <functional> #include <cstring> namespace boost { namespace core { class typeinfo { private: typeinfo( typeinfo const& ); typeinfo& operator=( typeinfo const& ); char const * name_; void (*lib_id_)(); public: typeinfo( char const * name, void (*lib_id)() ): name_( name ), lib_id_( lib_id ) { } bool operator==( typeinfo const& rhs ) const { #if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION) return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0; #else return this == &rhs; #endif } bool operator!=( typeinfo const& rhs ) const { return !( *this == rhs ); } bool before( typeinfo const& rhs ) const { #if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION) return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0; #else return std::less< typeinfo const* >()( this, &rhs ); #endif } char const* name() const { return name_; } }; inline char const * demangled_name( core::typeinfo const & ti ) { return ti.name(); } } // namespace core namespace detail { template<class T> struct BOOST_SYMBOL_VISIBLE core_typeid_ { static boost::core::typeinfo ti_; static char const * name() { return BOOST_CURRENT_FUNCTION; } }; BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id() { } template<class T> boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id ); template<class T> struct core_typeid_< T & >: core_typeid_< T > { }; template<class T> struct core_typeid_< T const >: core_typeid_< T > { }; template<class T> struct core_typeid_< T volatile >: core_typeid_< T > { }; template<class T> struct core_typeid_< T const volatile >: core_typeid_< T > { }; } // namespace detail } // namespace boost #define BOOST_CORE_TYPEID(T) (boost::detail::core_typeid_<T>::ti_) #else #include <boost/core/demangle.hpp> #include <typeinfo> namespace boost { namespace core { #if defined( BOOST_NO_STD_TYPEINFO ) typedef ::type_info typeinfo; #else typedef std::type_info typeinfo; #endif inline std::string demangled_name( core::typeinfo const & ti ) { return core::demangle( ti.name() ); } } // namespace core } // namespace boost #define BOOST_CORE_TYPEID(T) typeid(T) #endif #endif // #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED noncopyable.hpp 0000644 00000003567 15125235435 0007606 0 ustar 00 // Boost noncopyable.hpp header file --------------------------------------// // (C) Copyright Beman Dawes 1999-2003. 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/utility for documentation. #ifndef BOOST_CORE_NONCOPYABLE_HPP #define BOOST_CORE_NONCOPYABLE_HPP #include <boost/config.hpp> namespace boost { // Private copy constructor and copy assignment ensure classes derived from // class noncopyable cannot be copied. // Contributed by Dave Abrahams namespace noncopyable_ // protection from unintended ADL { #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED #define BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED // noncopyable derives from base_token to enable Type Traits to detect // whether a type derives from noncopyable without needing the definition // of noncopyable itself. // // The definition of base_token is macro-guarded so that Type Trais can // define it locally without including this header, to avoid a dependency // on Core. struct base_token {}; #endif // #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED class noncopyable: base_token { protected: #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS) BOOST_CONSTEXPR noncopyable() = default; ~noncopyable() = default; #else noncopyable() {} ~noncopyable() {} #endif #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) noncopyable( const noncopyable& ) = delete; noncopyable& operator=( const noncopyable& ) = delete; #else private: // emphasize the following members are private noncopyable( const noncopyable& ); noncopyable& operator=( const noncopyable& ); #endif }; } typedef noncopyable_::noncopyable noncopyable; } // namespace boost #endif // BOOST_CORE_NONCOPYABLE_HPP nvp.hpp 0000644 00000001750 15125235435 0006070 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_NVP_HPP #define BOOST_CORE_NVP_HPP #include <boost/core/addressof.hpp> #include <boost/config.hpp> namespace boost { namespace serialization { template<class T> class nvp { public: nvp(const char* n, T& v) BOOST_NOEXCEPT : n_(n) , v_(boost::addressof(v)) { } const char* name() const BOOST_NOEXCEPT { return n_; } T& value() const BOOST_NOEXCEPT { return *v_; } const T& const_value() const BOOST_NOEXCEPT { return *v_; } private: const char* n_; T* v_; }; template<class T> inline const nvp<T> make_nvp(const char* n, T& v) BOOST_NOEXCEPT { return nvp<T>(n, v); } } /* serialization */ using serialization::nvp; using serialization::make_nvp; } /* boost */ #define BOOST_NVP(v) boost::make_nvp(BOOST_STRINGIZE(v), v) #endif allocator_access.hpp 0000644 00000037110 15125235435 0010565 0 ustar 00 /* Copyright 2020 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP #define BOOST_CORE_ALLOCATOR_ACCESS_HPP #include <boost/config.hpp> #if !defined(BOOST_NO_CXX11_ALLOCATOR) #include <boost/core/pointer_traits.hpp> #if !defined(BOOST_MSVC) #include <limits> #else #include <memory> #endif #include <type_traits> #endif #include <new> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include <utility> #endif namespace boost { namespace detail { #if defined(BOOST_NO_CXX11_ALLOCATOR) struct alloc_false { BOOST_STATIC_CONSTEXPR bool value = false; }; #else template<class> struct alloc_void { typedef void type; }; #endif } /* detail */ template<class A> struct allocator_value_type { typedef typename A::value_type type; }; #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_pointer { typedef typename A::pointer type; }; #elif defined(BOOST_MSVC) template<class A> struct allocator_pointer { typedef typename std::allocator_traits<A>::pointer type; }; #else template<class A, class = void> struct allocator_pointer { typedef typename A::value_type* type; }; template<class A> struct allocator_pointer<A, typename detail::alloc_void<typename A::pointer>::type> { typedef typename A::pointer type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_const_pointer { typedef typename A::const_pointer type; }; #elif defined(BOOST_MSVC) template<class A> struct allocator_const_pointer { typedef typename std::allocator_traits<A>::const_pointer type; }; #else template<class A, class = void> struct allocator_const_pointer { typedef typename pointer_traits<typename allocator_pointer<A>::type>::template rebind_to<const typename A::value_type>::type type; }; template<class A> struct allocator_const_pointer<A, typename detail::alloc_void<typename A::const_pointer>::type> { typedef typename A::const_pointer type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_void_pointer { typedef typename A::template rebind<void>::other::pointer type; }; #else template<class A, class = void> struct allocator_void_pointer { typedef typename pointer_traits<typename allocator_pointer<A>::type>::template rebind_to<void>::type type; }; template<class A> struct allocator_void_pointer<A, typename detail::alloc_void<typename A::void_pointer>::type> { typedef typename A::void_pointer type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_const_void_pointer { typedef typename A::template rebind<void>::other::const_pointer type; }; #else template<class A, class = void> struct allocator_const_void_pointer { typedef typename pointer_traits<typename allocator_pointer<A>::type>::template rebind_to<const void>::type type; }; template<class A> struct allocator_const_void_pointer<A, typename detail::alloc_void<typename A::const_void_pointer>::type> { typedef typename A::const_void_pointer type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_difference_type { typedef typename A::difference_type type; }; #elif defined(BOOST_MSVC) template<class A> struct allocator_difference_type { typedef typename std::allocator_traits<A>::difference_type type; }; #else template<class A, class = void> struct allocator_difference_type { typedef typename pointer_traits<typename allocator_pointer<A>::type>::difference_type type; }; template<class A> struct allocator_difference_type<A, typename detail::alloc_void<typename A::difference_type>::type> { typedef typename A::difference_type type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_size_type { typedef typename A::size_type type; }; #elif defined(BOOST_MSVC) template<class A> struct allocator_size_type { typedef typename std::allocator_traits<A>::size_type type; }; #else template<class A, class = void> struct allocator_size_type { typedef typename std::make_unsigned<typename allocator_difference_type<A>::type>::type type; }; template<class A> struct allocator_size_type<A, typename detail::alloc_void<typename A::size_type>::type> { typedef typename A::size_type type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_propagate_on_container_copy_assignment { typedef detail::alloc_false type; }; #else template<class A, class = void> struct allocator_propagate_on_container_copy_assignment { typedef std::false_type type; }; template<class A> struct allocator_propagate_on_container_copy_assignment<A, typename detail::alloc_void<typename A::propagate_on_container_copy_assignment>::type> { typedef typename A::propagate_on_container_copy_assignment type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_propagate_on_container_move_assignment { typedef detail::alloc_false type; }; #else template<class A, class = void> struct allocator_propagate_on_container_move_assignment { typedef std::false_type type; }; template<class A> struct allocator_propagate_on_container_move_assignment<A, typename detail::alloc_void<typename A::propagate_on_container_move_assignment>::type> { typedef typename A::propagate_on_container_move_assignment type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_propagate_on_container_swap { typedef detail::alloc_false type; }; #else template<class A, class = void> struct allocator_propagate_on_container_swap { typedef std::false_type type; }; template<class A> struct allocator_propagate_on_container_swap<A, typename detail::alloc_void<typename A::propagate_on_container_swap>::type> { typedef typename A::propagate_on_container_swap type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> struct allocator_is_always_equal { typedef detail::alloc_false type; }; #else template<class A, class = void> struct allocator_is_always_equal { typedef typename std::is_empty<A>::type type; }; template<class A> struct allocator_is_always_equal<A, typename detail::alloc_void<typename A::is_always_equal>::type> { typedef typename A::is_always_equal type; }; #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A, class T> struct allocator_rebind { typedef typename A::template rebind<T>::other type; }; #elif defined(BOOST_MSVC) template<class A, class T> struct allocator_rebind { typedef typename std::allocator_traits<A>::template rebind_alloc<T> type; }; #else namespace detail { template<class, class> struct alloc_to { }; template<template<class, class...> class A, class T, class U, class... V> struct alloc_to<A<U, V...>, T> { typedef A<T, V...> type; }; } /* detail */ template<class A, class T, class = void> struct allocator_rebind { typedef typename detail::alloc_to<A, T>::type type; }; template<class A, class T> struct allocator_rebind<A, T, typename detail::alloc_void<typename A::template rebind<T>::other>::type> { typedef typename A::template rebind<T>::other type; }; #endif template<class A> inline typename allocator_pointer<A>::type allocator_allocate(A& a, typename allocator_size_type<A>::type n) { return a.allocate(n); } template<class A> inline void allocator_deallocate(A& a, typename allocator_pointer<A>::type p, typename allocator_size_type<A>::type n) { a.deallocate(p, n); } #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> inline typename allocator_pointer<A>::type allocator_allocate(A& a, typename allocator_size_type<A>::type n, typename allocator_const_void_pointer<A>::type h) { return a.allocate(n, h); } #elif defined(BOOST_MSVC) template<class A> inline typename allocator_pointer<A>::type allocator_allocate(A& a, typename allocator_size_type<A>::type n, typename allocator_const_void_pointer<A>::type h) { return std::allocator_traits<A>::allocate(a, n, h); } #else namespace detail { template<class, class, class, class = void> struct alloc_has_allocate { BOOST_STATIC_CONSTEXPR bool value = false; }; template<class A, class N, class H> struct alloc_has_allocate<A, N, H, typename alloc_void<decltype(std::declval<A&>().allocate(std::declval<N>(), std::declval<H>()))>::type> { BOOST_STATIC_CONSTEXPR bool value = true; }; } /* detail */ template<class A> inline typename std::enable_if<detail::alloc_has_allocate<A, typename allocator_size_type<A>::type, typename allocator_const_void_pointer<A>::type>::value, typename allocator_pointer<A>::type>::type allocator_allocate(A& a, typename allocator_size_type<A>::type n, typename allocator_const_void_pointer<A>::type h) { return a.allocate(n, h); } template<class A> inline typename std::enable_if<!detail::alloc_has_allocate<A, typename allocator_size_type<A>::type, typename allocator_const_void_pointer<A>::type>::value, typename allocator_pointer<A>::type>::type allocator_allocate(A& a, typename allocator_size_type<A>::type n, typename allocator_const_void_pointer<A>::type) { return a.allocate(n); } #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A, class T> inline void allocator_construct(A&, T* p) { ::new((void*)p) T(); } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class A, class T, class V, class... Args> inline void allocator_construct(A&, T* p, V&& v, Args&&... args) { ::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...); } #else template<class A, class T, class V> inline void allocator_construct(A&, T* p, V&& v) { ::new((void*)p) T(std::forward<V>(v)); } #endif #else template<class A, class T, class V> inline void allocator_construct(A&, T* p, const V& v) { ::new((void*)p) T(v); } template<class A, class T, class V> inline void allocator_construct(A&, T* p, V& v) { ::new((void*)p) T(v); } #endif #elif defined(BOOST_MSVC) template<class A, class T, class... Args> inline void allocator_construct(A& a, T* p, Args&&... args) { std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...); } #else namespace detail { template<class, class, class, class...> struct alloc_has_construct { BOOST_STATIC_CONSTEXPR bool value = false; }; template<class A, class T, class... Args> struct alloc_has_construct<typename alloc_void<decltype(std::declval<A &>().construct(std::declval<T*>(), std::declval<Args&&>()...))>::type, A, T, Args...> { BOOST_STATIC_CONSTEXPR bool value = true; }; } /* detail */ template<class A, class T, class... Args> inline typename std::enable_if<detail::alloc_has_construct<void, A, T, Args...>::value>::type allocator_construct(A& a, T* p, Args&&... args) { a.construct(p, std::forward<Args>(args)...); } template<class A, class T, class... Args> inline typename std::enable_if<!detail::alloc_has_construct<void, A, T, Args...>::value>::type allocator_construct(A&, T* p, Args&&... args) { ::new((void*)p) T(std::forward<Args>(args)...); } #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A, class T> inline void allocator_destroy(A&, T* p) { p->~T(); (void)p; } #elif defined(BOOST_MSVC) template<class A, class T> inline void allocator_destroy(A& a, T* p) { std::allocator_traits<A>::destroy(a, p); } #else namespace detail { template<class, class, class = void> struct alloc_has_destroy { BOOST_STATIC_CONSTEXPR bool value = false; }; template<class A, class T> struct alloc_has_destroy<A, T, typename alloc_void<decltype(std::declval<A &>().destroy(std::declval<T*>()))>::type> { BOOST_STATIC_CONSTEXPR bool value = true; }; } /* detail */ template<class A, class T> inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type allocator_destroy(A& a, T* p) { a.destroy(p); } template<class A, class T> inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type allocator_destroy(A&, T* p) { p->~T(); (void)p; } #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> inline typename allocator_size_type<A>::type allocator_max_size(const A& a) { return a.max_size(); } #elif defined(BOOST_MSVC) template<class A> inline typename allocator_size_type<A>::type allocator_max_size(const A& a) { return std::allocator_traits<A>::max_size(a); } #else namespace detail { template<class, class = void> struct alloc_has_max_size { BOOST_STATIC_CONSTEXPR bool value = false; }; template<class A> struct alloc_has_max_size<A, typename alloc_void<decltype(std::declval<const A&>().max_size())>::type> { BOOST_STATIC_CONSTEXPR bool value = true; }; } /* detail */ template<class A> inline typename std::enable_if<detail::alloc_has_max_size<A>::value, typename allocator_size_type<A>::type>::type allocator_max_size(const A& a) { return a.max_size(); } template<class A> inline typename std::enable_if<!detail::alloc_has_max_size<A>::value, typename allocator_size_type<A>::type>::type allocator_max_size(const A&) { return (std::numeric_limits<typename allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type); } #endif #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A> inline A allocator_select_on_container_copy_construction(const A& a) { return a; } #elif defined(BOOST_MSVC) template<class A> inline A allocator_select_on_container_copy_construction(const A& a) { return std::allocator_traits<A>::select_on_container_copy_construction(a); } #else namespace detail { template<class, class = void> struct alloc_has_soccc { BOOST_STATIC_CONSTEXPR bool value = false; }; template<class A> struct alloc_has_soccc<A, typename alloc_void<decltype(std::declval<const A&>().select_on_container_copy_construction())>::type> { BOOST_STATIC_CONSTEXPR bool value = true; }; } /* detail */ template<class A> inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type allocator_select_on_container_copy_construction(const A& a) { return a.select_on_container_copy_construction(); } template<class A> inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type allocator_select_on_container_copy_construction(const A& a) { return a; } #endif #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class A> using allocator_value_type_t = typename allocator_value_type<A>::type; template<class A> using allocator_pointer_t = typename allocator_pointer<A>::type; template<class A> using allocator_const_pointer_t = typename allocator_const_pointer<A>::type; template<class A> using allocator_void_pointer_t = typename allocator_void_pointer<A>::type; template<class A> using allocator_const_void_pointer_t = typename allocator_const_void_pointer<A>::type; template<class A> using allocator_difference_type_t = typename allocator_difference_type<A>::type; template<class A> using allocator_size_type_t = typename allocator_size_type<A>::type; template<class A> using allocator_propagate_on_container_copy_assignment_t = typename allocator_propagate_on_container_copy_assignment<A>::type; template<class A> using allocator_propagate_on_container_move_assignment_t = typename allocator_propagate_on_container_move_assignment<A>::type; template<class A> using allocator_propagate_on_container_swap_t = typename allocator_propagate_on_container_swap<A>::type; template<class A> using allocator_is_always_equal_t = typename allocator_is_always_equal<A>::type; template<class A, class T> using allocator_rebind_t = typename allocator_rebind<A, T>::type; #endif } /* boost */ #endif ignore_unused.hpp 0000644 00000003670 15125235435 0010136 0 ustar 00 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // // 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_CORE_IGNORE_UNUSED_HPP #define BOOST_CORE_IGNORE_UNUSED_HPP #include <boost/config.hpp> namespace boost { #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES template <typename... Ts> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts const& ...) {} template <typename... Ts> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} #else template <typename T1> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&) {} template <typename T1, typename T2> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&) {} template <typename T1, typename T2, typename T3> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&) {} template <typename T1, typename T2, typename T3, typename T4> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&) {} template <typename T1, typename T2, typename T3, typename T4, typename T5> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&) {} template <typename T1> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} template <typename T1, typename T2> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} template <typename T1, typename T2, typename T3> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} template <typename T1, typename T2, typename T3, typename T4> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} template <typename T1, typename T2, typename T3, typename T4, typename T5> BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused() {} #endif } // namespace boost #endif // BOOST_CORE_IGNORE_UNUSED_HPP exchange.hpp 0000644 00000001617 15125235435 0007051 0 ustar 00 /* Copyright 2018 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_EXCHANGE_HPP #define BOOST_CORE_EXCHANGE_HPP #include <boost/config.hpp> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include <boost/config/workaround.hpp> #include <utility> #endif namespace boost { #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template<class T, class U> inline T exchange(T& t, const U& u) { T v = t; t = u; return v; } #else #if BOOST_WORKAROUND(BOOST_MSVC, < 1800) template<class T, class U> inline T exchange(T& t, U&& u) { T v = std::move(t); t = std::forward<U>(u); return v; } #else template<class T, class U = T> BOOST_CXX14_CONSTEXPR inline T exchange(T& t, U&& u) { T v = std::move(t); t = std::forward<U>(u); return v; } #endif #endif } /* boost */ #endif null_deleter.hpp 0000644 00000002320 15125235435 0007735 0 ustar 00 /* * Copyright Andrey Semashev 2007 - 2014. * 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) */ /*! * \file null_deleter.hpp * \author Andrey Semashev * \date 22.04.2007 * * This header contains a \c null_deleter implementation. This is an empty * function object that receives a pointer and does nothing with it. * Such empty deletion strategy may be convenient, for example, when * constructing <tt>shared_ptr</tt>s that point to some object that should not be * deleted (i.e. a variable on the stack or some global singleton, like <tt>std::cout</tt>). */ #ifndef BOOST_CORE_NULL_DELETER_HPP #define BOOST_CORE_NULL_DELETER_HPP #include <boost/config.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { //! A function object that does nothing and can be used as an empty deleter for \c shared_ptr struct null_deleter { //! Function object result type typedef void result_type; /*! * Does nothing */ template< typename T > void operator() (T*) const BOOST_NOEXCEPT {} }; } // namespace boost #endif // BOOST_CORE_NULL_DELETER_HPP scoped_enum.hpp 0000644 00000017310 15125235435 0007565 0 ustar 00 // scoped_enum.hpp ---------------------------------------------------------// // Copyright Beman Dawes, 2009 // Copyright (C) 2011-2012 Vicente J. Botet Escriba // Copyright (C) 2012 Anthony Williams // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt #ifndef BOOST_CORE_SCOPED_ENUM_HPP #define BOOST_CORE_SCOPED_ENUM_HPP #include <boost/config.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { #ifdef BOOST_NO_CXX11_SCOPED_ENUMS /** * Meta-function to get the native enum type associated to an enum class or its emulation. */ template <typename EnumType> struct native_type { /** * The member typedef type names the native enum type associated to the scoped enum, * which is it self if the compiler supports scoped enums or EnumType::enum_type if it is an emulated scoped enum. */ typedef typename EnumType::enum_type type; }; /** * Casts a scoped enum to its underlying type. * * This function is useful when working with scoped enum classes, which doens't implicitly convert to the underlying type. * @param v A scoped enum. * @returns The underlying type. * @throws No-throws. */ template <typename UnderlyingType, typename EnumType> inline BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT { return v.get_underlying_value_(); } /** * Casts a scoped enum to its native enum type. * * This function is useful to make programs portable when the scoped enum emulation can not be use where native enums can. * * EnumType the scoped enum type * * @param v A scoped enum. * @returns The native enum value. * @throws No-throws. */ template <typename EnumType> inline BOOST_CONSTEXPR typename EnumType::enum_type native_value(EnumType e) BOOST_NOEXCEPT { return e.get_native_value_(); } #else // BOOST_NO_CXX11_SCOPED_ENUMS template <typename EnumType> struct native_type { typedef EnumType type; }; template <typename UnderlyingType, typename EnumType> inline BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT { return static_cast<UnderlyingType>(v); } template <typename EnumType> inline BOOST_CONSTEXPR EnumType native_value(EnumType e) BOOST_NOEXCEPT { return e; } #endif // BOOST_NO_CXX11_SCOPED_ENUMS } #ifdef BOOST_NO_CXX11_SCOPED_ENUMS #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS #define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \ explicit BOOST_CONSTEXPR operator underlying_type() const BOOST_NOEXCEPT { return get_underlying_value_(); } #else #define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR #endif /** * Start a declaration of a scoped enum. * * @param EnumType The new scoped enum. * @param UnderlyingType The underlying type. */ #define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType, UnderlyingType) \ struct EnumType { \ typedef void is_boost_scoped_enum_tag; \ typedef UnderlyingType underlying_type; \ EnumType() BOOST_NOEXCEPT {} \ explicit BOOST_CONSTEXPR EnumType(underlying_type v) BOOST_NOEXCEPT : v_(v) {} \ BOOST_CONSTEXPR underlying_type get_underlying_value_() const BOOST_NOEXCEPT { return v_; } \ BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \ private: \ underlying_type v_; \ typedef EnumType self_type; \ public: \ enum enum_type #define BOOST_SCOPED_ENUM_DECLARE_END2() \ BOOST_CONSTEXPR enum_type get_native_value_() const BOOST_NOEXCEPT { return enum_type(v_); } \ friend BOOST_CONSTEXPR bool operator ==(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator ==(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==rhs; } \ friend BOOST_CONSTEXPR bool operator ==(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs==enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator !=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator !=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=rhs; } \ friend BOOST_CONSTEXPR bool operator !=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs!=enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator <(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator <(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<rhs; } \ friend BOOST_CONSTEXPR bool operator <(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator <=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator <=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=rhs; } \ friend BOOST_CONSTEXPR bool operator <=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<=enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator >(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator >(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>rhs; } \ friend BOOST_CONSTEXPR bool operator >(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator >=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=enum_type(rhs.v_); } \ friend BOOST_CONSTEXPR bool operator >=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=rhs; } \ friend BOOST_CONSTEXPR bool operator >=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>=enum_type(rhs.v_); } \ }; #define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) \ ; \ BOOST_CONSTEXPR EnumType(enum_type v) BOOST_NOEXCEPT : v_(v) {} \ BOOST_SCOPED_ENUM_DECLARE_END2() /** * Starts a declaration of a scoped enum with the default int underlying type. * * @param EnumType The new scoped enum. */ #define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) \ BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,int) /** * Name of the native enum type. * * @param EnumType The new scoped enum. */ #define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType::enum_type /** * Forward declares an scoped enum. * * @param EnumType The scoped enum. */ #define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) struct EnumType #else // BOOST_NO_CXX11_SCOPED_ENUMS #define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,UnderlyingType) enum class EnumType : UnderlyingType #define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) enum class EnumType #define BOOST_SCOPED_ENUM_DECLARE_END2() #define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) ; #define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType #define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) enum class EnumType #endif // BOOST_NO_CXX11_SCOPED_ENUMS // Deprecated macros #define BOOST_SCOPED_ENUM_START(name) BOOST_SCOPED_ENUM_DECLARE_BEGIN(name) #define BOOST_SCOPED_ENUM_END BOOST_SCOPED_ENUM_DECLARE_END2() #define BOOST_SCOPED_ENUM(name) BOOST_SCOPED_ENUM_NATIVE(name) #endif // BOOST_CORE_SCOPED_ENUM_HPP alloc_construct.hpp 0000644 00000006554 15125235435 0010472 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP #define BOOST_CORE_ALLOC_CONSTRUCT_HPP #include <boost/core/noinit_adaptor.hpp> namespace boost { template<class A, class T> inline void alloc_destroy(A& a, T* p) { boost::allocator_destroy(a, p); } template<class A, class T> inline void alloc_destroy_n(A& a, T* p, std::size_t n) { while (n > 0) { boost::allocator_destroy(a, p + --n); } } template<class A, class T> inline void alloc_destroy(noinit_adaptor<A>&, T* p) { p->~T(); } template<class A, class T> inline void alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n) { while (n > 0) { p[--n].~T(); } } namespace detail { template<class A, class T> class alloc_destroyer { public: alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT : a_(a), p_(p), n_(0) { } ~alloc_destroyer() { boost::alloc_destroy_n(a_, p_, n_); } std::size_t& size() BOOST_NOEXCEPT { return n_; } private: alloc_destroyer(const alloc_destroyer&); alloc_destroyer& operator=(const alloc_destroyer&); A& a_; T* p_; std::size_t n_; }; } /* detail */ template<class A, class T> inline void alloc_construct(A& a, T* p) { boost::allocator_construct(a, p); } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class A, class T, class U, class... V> inline void alloc_construct(A& a, T* p, U&& u, V&&... v) { boost::allocator_construct(a, p, std::forward<U>(u), std::forward<V>(v)...); } #else template<class A, class T, class U> inline void alloc_construct(A& a, T* p, U&& u) { boost::allocator_construct(a, p, std::forward<U>(u)); } #endif #else template<class A, class T, class U> inline void alloc_construct(A& a, T* p, const U& u) { boost::allocator_construct(a, p, u); } template<class A, class T, class U> inline void alloc_construct(A& a, T* p, U& u) { boost::allocator_construct(a, p, u); } #endif template<class A, class T> inline void alloc_construct_n(A& a, T* p, std::size_t n) { detail::alloc_destroyer<A, T> hold(a, p); for (std::size_t& i = hold.size(); i < n; ++i) { boost::allocator_construct(a, p + i); } hold.size() = 0; } template<class A, class T> inline void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m) { detail::alloc_destroyer<A, T> hold(a, p); for (std::size_t& i = hold.size(); i < n; ++i) { boost::allocator_construct(a, p + i, l[i % m]); } hold.size() = 0; } template<class A, class T, class I> inline void alloc_construct_n(A& a, T* p, std::size_t n, I b) { detail::alloc_destroyer<A, T> hold(a, p); for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) { boost::allocator_construct(a, p + i, *b); } hold.size() = 0; } template<class A, class T> inline void alloc_construct(noinit_adaptor<A>&, T* p) { ::new(static_cast<void*>(p)) T; } template<class A, class T> inline void alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n) { detail::alloc_destroyer<noinit_adaptor<A>, T> hold(a, p); for (std::size_t& i = hold.size(); i < n; ++i) { ::new(static_cast<void*>(p + i)) T; } hold.size() = 0; } } /* boost */ #endif ref.hpp 0000644 00000013530 15125235435 0006040 0 ustar 00 #ifndef BOOST_CORE_REF_HPP #define BOOST_CORE_REF_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include <boost/config.hpp> #include <boost/config/workaround.hpp> #include <boost/core/addressof.hpp> // // ref.hpp - ref/cref, useful helper functions // // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2002 David Abrahams // // Copyright (C) 2014 Glen Joseph Fernandes // (glenjofe@gmail.com) // // Copyright (C) 2014 Agustin Berge // // 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/core/doc/html/core/ref.html for documentation. // /** @file */ /** Boost namespace. */ namespace boost { #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) struct ref_workaround_tag {}; #endif // reference_wrapper /** @brief Contains a reference to an object of type `T`. `reference_wrapper` is primarily used to "feed" references to function templates (algorithms) that take their parameter by value. It provides an implicit conversion to `T&`, which usually allows the function templates to work on references unmodified. */ template<class T> class reference_wrapper { public: /** Type `T`. */ typedef T type; /** Constructs a `reference_wrapper` object that stores a reference to `t`. @remark Does not throw. */ BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ): t_( boost::addressof( t ) ) {} #endif #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) /** @remark Construction from a temporary object is disabled. */ BOOST_DELETED_FUNCTION(reference_wrapper(T&& t)) public: #endif /** @return The stored reference. @remark Does not throw. */ BOOST_FORCEINLINE operator T& () const { return *t_; } /** @return The stored reference. @remark Does not throw. */ BOOST_FORCEINLINE T& get() const { return *t_; } /** @return A pointer to the object referenced by the stored reference. @remark Does not throw. */ BOOST_FORCEINLINE T* get_pointer() const { return t_; } private: T* t_; }; // ref /** @cond */ #if defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) ) # define BOOST_REF_CONST #else # define BOOST_REF_CONST const #endif /** @endcond */ /** @return `reference_wrapper<T>(t)` @remark Does not throw. */ template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T & t ) { #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) return reference_wrapper<T>( t, ref_workaround_tag() ); #else return reference_wrapper<T>( t ); #endif } // cref /** @return `reference_wrapper<T const>(t)` @remark Does not throw. */ template<class T> BOOST_FORCEINLINE reference_wrapper<T const> BOOST_REF_CONST cref( T const & t ) { return reference_wrapper<T const>(t); } #undef BOOST_REF_CONST #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) /** @cond */ #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) # define BOOST_REF_DELETE #else # define BOOST_REF_DELETE = delete #endif /** @endcond */ /** @remark Construction from a temporary object is disabled. */ template<class T> void ref(T const&&) BOOST_REF_DELETE; /** @remark Construction from a temporary object is disabled. */ template<class T> void cref(T const&&) BOOST_REF_DELETE; #undef BOOST_REF_DELETE #endif // is_reference_wrapper /** @brief Determine if a type `T` is an instantiation of `reference_wrapper`. The value static constant will be true if the type `T` is a specialization of `reference_wrapper`. */ template<typename T> struct is_reference_wrapper { BOOST_STATIC_CONSTANT( bool, value = false ); }; /** @cond */ template<typename T> struct is_reference_wrapper< reference_wrapper<T> > { BOOST_STATIC_CONSTANT( bool, value = true ); }; #if !defined(BOOST_NO_CV_SPECIALIZATIONS) template<typename T> struct is_reference_wrapper< reference_wrapper<T> const > { BOOST_STATIC_CONSTANT( bool, value = true ); }; template<typename T> struct is_reference_wrapper< reference_wrapper<T> volatile > { BOOST_STATIC_CONSTANT( bool, value = true ); }; template<typename T> struct is_reference_wrapper< reference_wrapper<T> const volatile > { BOOST_STATIC_CONSTANT( bool, value = true ); }; #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS) /** @endcond */ // unwrap_reference /** @brief Find the type in a `reference_wrapper`. The `typedef` type is `T::type` if `T` is a `reference_wrapper`, `T` otherwise. */ template<typename T> struct unwrap_reference { typedef T type; }; /** @cond */ template<typename T> struct unwrap_reference< reference_wrapper<T> > { typedef T type; }; #if !defined(BOOST_NO_CV_SPECIALIZATIONS) template<typename T> struct unwrap_reference< reference_wrapper<T> const > { typedef T type; }; template<typename T> struct unwrap_reference< reference_wrapper<T> volatile > { typedef T type; }; template<typename T> struct unwrap_reference< reference_wrapper<T> const volatile > { typedef T type; }; #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS) /** @endcond */ // unwrap_ref /** @return `unwrap_reference<T>::type&(t)` @remark Does not throw. */ template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_ref( T & t ) { return t; } // get_pointer /** @cond */ template<class T> BOOST_FORCEINLINE T* get_pointer( reference_wrapper<T> const & r ) { return r.get_pointer(); } /** @endcond */ } // namespace boost #endif // #ifndef BOOST_CORE_REF_HPP default_allocator.hpp 0000644 00000006405 15125235435 0010753 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_DEFAULT_ALLOCATOR_HPP #define BOOST_CORE_DEFAULT_ALLOCATOR_HPP #include <boost/config.hpp> #include <new> namespace boost { #if defined(BOOST_NO_EXCEPTIONS) BOOST_NORETURN void throw_exception(const std::exception&); #endif namespace default_ { struct true_type { typedef bool value_type; typedef true_type type; BOOST_STATIC_CONSTANT(bool, value = true); BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT { return true; } BOOST_CONSTEXPR bool operator()() const BOOST_NOEXCEPT { return true; } }; template<class T> struct add_reference { typedef T& type; }; template<> struct add_reference<void> { typedef void type; }; template<> struct add_reference<const void> { typedef const void type; }; template<class T> struct default_allocator { typedef T value_type; typedef T* pointer; typedef const T* const_pointer; typedef typename add_reference<T>::type reference; typedef typename add_reference<const T>::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef true_type propagate_on_container_move_assignment; typedef true_type is_always_equal; template<class U> struct rebind { typedef default_allocator<U> other; }; #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) default_allocator() = default; #else BOOST_CONSTEXPR default_allocator() BOOST_NOEXCEPT { } #endif template<class U> BOOST_CONSTEXPR default_allocator(const default_allocator<U>&) BOOST_NOEXCEPT { } BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT { return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2); } #if !defined(BOOST_NO_EXCEPTIONS) T* allocate(std::size_t n) { if (n > max_size()) { throw std::bad_alloc(); } return static_cast<T*>(::operator new(sizeof(T) * n)); } void deallocate(T* p, std::size_t) { ::operator delete(p); } #else T* allocate(std::size_t n) { if (n > max_size()) { boost::throw_exception(std::bad_alloc()); } void* p = ::operator new(sizeof(T) * n, std::nothrow); if (!p) { boost::throw_exception(std::bad_alloc()); } return static_cast<T*>(p); } void deallocate(T* p, std::size_t) { ::operator delete(p, std::nothrow); } #endif #if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \ defined(BOOST_NO_CXX11_ALLOCATOR) template<class U, class V> void construct(U* p, const V& v) { ::new(p) U(v); } template<class U> void destroy(U* p) { p->~U(); (void)p; } #endif }; template<class T, class U> BOOST_CONSTEXPR inline bool operator==(const default_allocator<T>&, const default_allocator<U>&) BOOST_NOEXCEPT { return true; } template<class T, class U> BOOST_CONSTEXPR inline bool operator!=(const default_allocator<T>&, const default_allocator<U>&) BOOST_NOEXCEPT { return false; } } /* default_ */ using default_::default_allocator; } /* boost */ #endif empty_value.hpp 0000644 00000006374 15125235435 0007626 0 ustar 00 /* Copyright 2018 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_EMPTY_VALUE_HPP #define BOOST_CORE_EMPTY_VALUE_HPP #include <boost/config.hpp> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include <utility> #endif #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700) #define BOOST_DETAIL_EMPTY_VALUE_BASE #elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1800) #define BOOST_DETAIL_EMPTY_VALUE_BASE #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1800) #define BOOST_DETAIL_EMPTY_VALUE_BASE #elif defined(BOOST_CLANG) && !defined(__CUDACC__) #if __has_feature(is_empty) && __has_feature(is_final) #define BOOST_DETAIL_EMPTY_VALUE_BASE #endif #endif namespace boost { template<class T> struct use_empty_value_base { enum { #if defined(BOOST_DETAIL_EMPTY_VALUE_BASE) value = __is_empty(T) && !__is_final(T) #else value = false #endif }; }; struct empty_init_t { }; namespace empty_ { template<class T, unsigned N = 0, bool E = boost::use_empty_value_base<T>::value> class empty_value { public: typedef T type; #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) empty_value() = default; #else empty_value() { } #endif empty_value(boost::empty_init_t) : value_() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class U, class... Args> empty_value(boost::empty_init_t, U&& value, Args&&... args) : value_(std::forward<U>(value), std::forward<Args>(args)...) { } #else template<class U> empty_value(boost::empty_init_t, U&& value) : value_(std::forward<U>(value)) { } #endif #else template<class U> empty_value(boost::empty_init_t, const U& value) : value_(value) { } template<class U> empty_value(boost::empty_init_t, U& value) : value_(value) { } #endif const T& get() const BOOST_NOEXCEPT { return value_; } T& get() BOOST_NOEXCEPT { return value_; } private: T value_; }; #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template<class T, unsigned N> class empty_value<T, N, true> : T { public: typedef T type; #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) empty_value() = default; #else empty_value() { } #endif empty_value(boost::empty_init_t) : T() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class U, class... Args> empty_value(boost::empty_init_t, U&& value, Args&&... args) : T(std::forward<U>(value), std::forward<Args>(args)...) { } #else template<class U> empty_value(boost::empty_init_t, U&& value) : T(std::forward<U>(value)) { } #endif #else template<class U> empty_value(boost::empty_init_t, const U& value) : T(value) { } template<class U> empty_value(boost::empty_init_t, U& value) : T(value) { } #endif const T& get() const BOOST_NOEXCEPT { return *this; } T& get() BOOST_NOEXCEPT { return *this; } }; #endif } /* empty_ */ using empty_::empty_value; BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t(); } /* boost */ #endif enable_if.hpp 0000644 00000006363 15125235435 0007176 0 ustar 00 // Boost enable_if library // Copyright 2003 (c) 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) // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) #ifndef BOOST_CORE_ENABLE_IF_HPP #define BOOST_CORE_ENABLE_IF_HPP #include "boost/config.hpp" // Even the definition of enable_if causes problems on some compilers, // so it's macroed out for all compilers that do not support SFINAE #ifndef BOOST_NO_SFINAE namespace boost { template<typename T, typename R=void> struct enable_if_has_type { typedef R type; }; template <bool B, class T = void> struct enable_if_c { typedef T type; }; template <class T> struct enable_if_c<false, T> {}; template <class Cond, class T = void> struct enable_if : public enable_if_c<Cond::value, T> {}; template <bool B, class T> struct lazy_enable_if_c { typedef typename T::type type; }; template <class T> struct lazy_enable_if_c<false, T> {}; template <class Cond, class T> struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {}; template <bool B, class T = void> struct disable_if_c { typedef T type; }; template <class T> struct disable_if_c<true, T> {}; template <class Cond, class T = void> struct disable_if : public disable_if_c<Cond::value, T> {}; template <bool B, class T> struct lazy_disable_if_c { typedef typename T::type type; }; template <class T> struct lazy_disable_if_c<true, T> {}; template <class Cond, class T> struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {}; } // namespace boost #else namespace boost { namespace detail { typedef void enable_if_default_T; } template <typename T> struct enable_if_does_not_work_on_this_compiler; template<typename T, typename R=void> struct enable_if_has_type : enable_if_does_not_work_on_this_compiler<T> { }; template <bool B, class T = detail::enable_if_default_T> struct enable_if_c : enable_if_does_not_work_on_this_compiler<T> { }; template <bool B, class T = detail::enable_if_default_T> struct disable_if_c : enable_if_does_not_work_on_this_compiler<T> { }; template <bool B, class T = detail::enable_if_default_T> struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T> { }; template <bool B, class T = detail::enable_if_default_T> struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T> { }; template <class Cond, class T = detail::enable_if_default_T> struct enable_if : enable_if_does_not_work_on_this_compiler<T> { }; template <class Cond, class T = detail::enable_if_default_T> struct disable_if : enable_if_does_not_work_on_this_compiler<T> { }; template <class Cond, class T = detail::enable_if_default_T> struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T> { }; template <class Cond, class T = detail::enable_if_default_T> struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T> { }; } // namespace boost #endif // BOOST_NO_SFINAE #endif swap.hpp 0000644 00000004113 15125235435 0006233 0 ustar 00 // Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker // // 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) // For more information, see http://www.boost.org #ifndef BOOST_CORE_SWAP_HPP #define BOOST_CORE_SWAP_HPP // Note: the implementation of this utility contains various workarounds: // - swap_impl is put outside the boost namespace, to avoid infinite // recursion (causing stack overflow) when swapping objects of a primitive // type. // - swap_impl has a using-directive, rather than a using-declaration, // because some compilers (including MSVC 7.1, Borland 5.9.3, and // Intel 8.1) don't do argument-dependent lookup when it has a // using-declaration instead. // - boost::swap has two template arguments, instead of one, to // avoid ambiguity when swapping objects of a Boost type that does // not have its own boost::swap overload. #include <boost/core/enable_if.hpp> #include <boost/config.hpp> #if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB) #include <utility> // for std::swap (C++11) #else #include <algorithm> // for std::swap (C++98) #endif #include <cstddef> // for std::size_t namespace boost_swap_impl { // we can't use type_traits here template<class T> struct is_const { enum _vt { value = 0 }; }; template<class T> struct is_const<T const> { enum _vt { value = 1 }; }; template<class T> BOOST_GPU_ENABLED void swap_impl(T& left, T& right) { using namespace std;//use std::swap if argument dependent lookup fails swap(left,right); } template<class T, std::size_t N> BOOST_GPU_ENABLED void swap_impl(T (& left)[N], T (& right)[N]) { for (std::size_t i = 0; i < N; ++i) { ::boost_swap_impl::swap_impl(left[i], right[i]); } } } namespace boost { template<class T1, class T2> BOOST_GPU_ENABLED typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type swap(T1& left, T2& right) { ::boost_swap_impl::swap_impl(left, right); } } #endif lightweight_test.hpp 0000644 00000044013 15125235435 0010642 0 ustar 00 #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP #define BOOST_CORE_LIGHTWEIGHT_TEST_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif // // boost/core/lightweight_test.hpp - lightweight test library // // Copyright (c) 2002, 2009, 2014 Peter Dimov // Copyright (2) Beman Dawes 2010, 2011 // Copyright (3) Ion Gaztanaga 2013 // // Copyright 2018 Glen Joseph Fernandes // (glenjofe@gmail.com) // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // #include <boost/current_function.hpp> #include <boost/config.hpp> #include <exception> #include <iostream> #include <iterator> #include <cstdlib> #include <cstring> #include <cstddef> #if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG) # include <crtdbg.h> #endif // IDE's like Visual Studio perform better if output goes to std::cout or // some other stream, so allow user to configure output stream: #ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM # define BOOST_LIGHTWEIGHT_TEST_OSTREAM std::cerr #endif namespace boost { namespace detail { class test_result { public: test_result() : report_(false) , errors_(0) { #if defined(_MSC_VER) && (_MSC_VER > 1310) // disable message boxes on assert(), abort() ::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif #if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG) // disable message boxes on iterator debugging violations _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR ); #endif } ~test_result() { if (!report_) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl; std::abort(); } } int& errors() { return errors_; } void done() { report_ = true; } private: bool report_; int errors_; }; inline test_result& test_results() { static test_result instance; return instance; } inline int& test_errors() { return test_results().errors(); } inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v) { if( v ) { test_results(); return true; } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl; ++test_results().errors(); return false; } } inline void error_impl(char const * msg, char const * file, int line, char const * function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl; ++test_results().errors(); } inline void throw_failed_impl(const char* expr, char const * excep, char const * file, int line, char const * function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): expression '" << expr << "' did not throw exception '" << excep << "' in function '" << function << "'" << std::endl; ++test_results().errors(); } inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): expression '" << expr << "' threw an exception in function '" << function << "'" << std::endl; ++test_results().errors(); } inline void no_throw_failed_impl(const char* expr, const char* what, const char* file, int line, const char* function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): expression '" << expr << "' threw an exception in function '" << function << "': " << what << std::endl; ++test_results().errors(); } // In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers. // A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid // the dependency we just disable the warnings. #if defined(__clang__) && defined(__has_warning) # if __has_warning("-Wsign-compare") # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-compare" # endif #elif defined(_MSC_VER) # pragma warning(push) # pragma warning(disable: 4389) #elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" #endif // specialize test output for char pointers to avoid printing as cstring template <class T> inline const T& test_output_impl(const T& v) { return v; } inline const void* test_output_impl(const char* v) { return v; } inline const void* test_output_impl(const unsigned char* v) { return v; } inline const void* test_output_impl(const signed char* v) { return v; } inline const void* test_output_impl(char* v) { return v; } inline const void* test_output_impl(unsigned char* v) { return v; } inline const void* test_output_impl(signed char* v) { return v; } template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); } #if !defined( BOOST_NO_CXX11_NULLPTR ) inline const void* test_output_impl(std::nullptr_t) { return nullptr; } #endif // predicates struct lw_test_eq { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t == u; } }; struct lw_test_ne { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t != u; } }; struct lw_test_lt { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t < u; } }; struct lw_test_le { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t <= u; } }; struct lw_test_gt { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t > u; } }; struct lw_test_ge { template <typename T, typename U> bool operator()(const T& t, const U& u) const { return t >= u; } }; // lwt_predicate_name template<class T> char const * lwt_predicate_name( T const& ) { return "~="; } inline char const * lwt_predicate_name( lw_test_eq const& ) { return "=="; } inline char const * lwt_predicate_name( lw_test_ne const& ) { return "!="; } inline char const * lwt_predicate_name( lw_test_lt const& ) { return "<"; } inline char const * lwt_predicate_name( lw_test_le const& ) { return "<="; } inline char const * lwt_predicate_name( lw_test_gt const& ) { return ">"; } inline char const * lwt_predicate_name( lw_test_ge const& ) { return ">="; } // template<class BinaryPredicate, class T, class U> inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u) { if( pred(t, u) ) { test_results(); return true; } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " " << lwt_predicate_name(pred) << " " << expr2 << "' ('" << test_output_impl(t) << "' " << lwt_predicate_name(pred) << " '" << test_output_impl(u) << "') failed in function '" << function << "'" << std::endl; ++test_results().errors(); return false; } } inline bool test_cstr_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, char const * const t, char const * const u ) { if( std::strcmp(t, u) == 0 ) { test_results(); return true; } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t << "' == '" << u << "') failed in function '" << function << "'" << std::endl; ++test_results().errors(); return false; } } inline bool test_cstr_ne_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, char const * const t, char const * const u ) { if( std::strcmp(t, u) != 0 ) { test_results(); return true; } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t << "' != '" << u << "') failed in function '" << function << "'" << std::endl; ++test_results().errors(); return false; } } template<class FormattedOutputFunction, class InputIterator1, class InputIterator2> bool test_all_eq_impl(FormattedOutputFunction& output, char const * file, int line, char const * function, InputIterator1 first_begin, InputIterator1 first_end, InputIterator2 second_begin, InputIterator2 second_end) { InputIterator1 first_it = first_begin; InputIterator2 second_it = second_begin; typename std::iterator_traits<InputIterator1>::difference_type first_index = 0; typename std::iterator_traits<InputIterator2>::difference_type second_index = 0; std::size_t error_count = 0; const std::size_t max_count = 8; do { while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) { ++first_it; ++second_it; ++first_index; ++second_index; } if ((first_it == first_end) || (second_it == second_end)) { break; // do-while } if (error_count == 0) { output << file << "(" << line << "): Container contents differ in function '" << function << "':"; } else if (error_count >= max_count) { output << " ..."; break; } output << " [" << first_index << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'"; ++first_it; ++second_it; ++first_index; ++second_index; ++error_count; } while (first_it != first_end); first_index += std::distance(first_it, first_end); second_index += std::distance(second_it, second_end); if (first_index != second_index) { if (error_count == 0) { output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")"; } else { output << " [*] size(" << first_index << ") != size(" << second_index << ")"; } ++error_count; } if (error_count == 0) { test_results(); return true; } else { output << std::endl; ++test_results().errors(); return false; } } template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate> bool test_all_with_impl(FormattedOutputFunction& output, char const * file, int line, char const * function, InputIterator1 first_begin, InputIterator1 first_end, InputIterator2 second_begin, InputIterator2 second_end, BinaryPredicate predicate) { InputIterator1 first_it = first_begin; InputIterator2 second_it = second_begin; typename std::iterator_traits<InputIterator1>::difference_type first_index = 0; typename std::iterator_traits<InputIterator2>::difference_type second_index = 0; std::size_t error_count = 0; const std::size_t max_count = 8; do { while ((first_it != first_end) && (second_it != second_end) && predicate(*first_it, *second_it)) { ++first_it; ++second_it; ++first_index; ++second_index; } if ((first_it == first_end) || (second_it == second_end)) { break; // do-while } if (error_count == 0) { output << file << "(" << line << "): Container contents differ in function '" << function << "':"; } else if (error_count >= max_count) { output << " ..."; break; } output << " [" << first_index << "]"; ++first_it; ++second_it; ++first_index; ++second_index; ++error_count; } while (first_it != first_end); first_index += std::distance(first_it, first_end); second_index += std::distance(second_it, second_end); if (first_index != second_index) { if (error_count == 0) { output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")"; } else { output << " [*] size(" << first_index << ") != size(" << second_index << ")"; } ++error_count; } if (error_count == 0) { test_results(); return true; } else { output << std::endl; ++test_results().errors(); return false; } } #if defined(__clang__) && defined(__has_warning) # if __has_warning("-Wsign-compare") # pragma clang diagnostic pop # endif #elif defined(_MSC_VER) # pragma warning(pop) #elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 # pragma GCC diagnostic pop #endif } // namespace detail inline int report_errors() { boost::detail::test_result& result = boost::detail::test_results(); result.done(); int errors = result.errors(); if( errors == 0 ) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << "No errors detected." << std::endl; } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl; } // `return report_errors();` from main only supports 8 bit exit codes return errors < 256? errors: 255; } } // namespace boost #define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) ) #define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr)) #define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) #define BOOST_TEST_WITH(expr1,expr2,predicate) ( ::boost::detail::test_with_impl(predicate, #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_lt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_le(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_gt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ge(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) ) #define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) ) #ifndef BOOST_NO_EXCEPTIONS #define BOOST_TEST_THROWS( EXPR, EXCEP ) \ try { \ EXPR; \ ::boost::detail::throw_failed_impl \ (#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } \ catch(EXCEP const&) { \ ::boost::detail::test_results(); \ } \ catch(...) { \ ::boost::detail::throw_failed_impl \ (#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } \ // #else #define BOOST_TEST_THROWS( EXPR, EXCEP ) #endif #ifndef BOOST_NO_EXCEPTIONS # define BOOST_TEST_NO_THROW(EXPR) \ try { \ EXPR; \ } catch (const std::exception& e) { \ ::boost::detail::no_throw_failed_impl \ (#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } catch (...) { \ ::boost::detail::no_throw_failed_impl \ (#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } // #else # define BOOST_TEST_NO_THROW(EXPR) { EXPR; } #endif #endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP quick_exit.hpp 0000644 00000002112 15125235435 0007423 0 ustar 00 #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED #define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // boost/core/quick_exit.hpp // // Copyright 2018 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/config.hpp> #include <stdlib.h> #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) extern "C" _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN; #endif #if defined(__CYGWIN__) && __cplusplus < 201103L extern "C" _Noreturn void quick_exit(int); #endif namespace boost { BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT { #if defined(_MSC_VER) && _MSC_VER < 1900 ::_exit( code ); #elif defined(__MINGW32__) ::_exit( code ); #elif defined(__APPLE__) ::_Exit( code ); #else ::quick_exit( code ); #endif } } // namespace boost #endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED is_same.hpp 0000644 00000001431 15125235435 0006701 0 ustar 00 #ifndef BOOST_CORE_IS_SAME_HPP_INCLUDED #define BOOST_CORE_IS_SAME_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // is_same<T1,T2>::value is true when T1 == T2 // // Copyright 2014 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include <boost/config.hpp> namespace boost { namespace core { template< class T1, class T2 > struct is_same { BOOST_STATIC_CONSTANT( bool, value = false ); }; template< class T > struct is_same< T, T > { BOOST_STATIC_CONSTANT( bool, value = true ); }; } // namespace core } // namespace boost #endif // #ifndef BOOST_CORE_IS_SAME_HPP_INCLUDED pointer_traits.hpp 0000644 00000011720 15125235435 0010331 0 ustar 00 /* Copyright 2017-2018 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_POINTER_TRAITS_HPP #define BOOST_CORE_POINTER_TRAITS_HPP #include <boost/config.hpp> #if !defined(BOOST_NO_CXX11_POINTER_TRAITS) #include <memory> #else #include <boost/core/addressof.hpp> #include <cstddef> #endif namespace boost { #if !defined(BOOST_NO_CXX11_POINTER_TRAITS) template<class T> struct pointer_traits : std::pointer_traits<T> { template<class U> struct rebind_to { typedef typename std::pointer_traits<T>::template rebind<U> type; }; }; template<class T> struct pointer_traits<T*> : std::pointer_traits<T*> { template<class U> struct rebind_to { typedef U* type; }; }; #else namespace detail { template<class> struct ptr_void { typedef void type; }; template<class T> struct ptr_first; #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<template<class, class...> class T, class U, class... Args> struct ptr_first<T<U, Args...> > { typedef U type; }; #else template<template<class> class T, class U> struct ptr_first<T<U> > { typedef U type; }; template<template<class, class> class T, class U1, class U2> struct ptr_first<T<U1, U2> > { typedef U1 type; }; template<template<class, class, class> class T, class U1, class U2, class U3> struct ptr_first<T<U1, U2, U3> > { typedef U1 type; }; #endif template<class T, class = void> struct ptr_element { typedef typename ptr_first<T>::type type; }; template<class T> struct ptr_element<T, typename ptr_void<typename T::element_type>::type> { typedef typename T::element_type type; }; template<class, class = void> struct ptr_difference { typedef std::ptrdiff_t type; }; template<class T> struct ptr_difference<T, typename ptr_void<typename T::difference_type>::type> { typedef typename T::difference_type type; }; template<class T, class V> struct ptr_transform; #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<template<class, class...> class T, class U, class... Args, class V> struct ptr_transform<T<U, Args...>, V> { typedef T<V, Args...> type; }; #else template<template<class> class T, class U, class V> struct ptr_transform<T<U>, V> { typedef T<V> type; }; template<template<class, class> class T, class U1, class U2, class V> struct ptr_transform<T<U1, U2>, V> { typedef T<V, U2> type; }; template<template<class, class, class> class T, class U1, class U2, class U3, class V> struct ptr_transform<T<U1, U2, U3>, V> { typedef T<V, U2, U3> type; }; #endif template<class T, class U, class = void> struct ptr_rebind { typedef typename ptr_transform<T, U>::type type; }; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class T, class U> struct ptr_rebind<T, U, typename ptr_void<typename T::template rebind<U> >::type> { typedef typename T::template rebind<U> type; }; #endif template<class T> struct ptr_value { typedef T type; }; template<> struct ptr_value<void> { typedef struct { } type; }; } /* detail */ template<class T> struct pointer_traits { typedef T pointer; typedef typename detail::ptr_element<T>::type element_type; typedef typename detail::ptr_difference<T>::type difference_type; template<class U> struct rebind_to { typedef typename detail::ptr_rebind<T, U>::type type; }; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class U> using rebind = typename detail::ptr_rebind<T, U>::type; #endif static pointer pointer_to(typename detail::ptr_value<element_type>::type& v) { return pointer::pointer_to(v); } }; template<class T> struct pointer_traits<T*> { typedef T* pointer; typedef T element_type; typedef std::ptrdiff_t difference_type; template<class U> struct rebind_to { typedef U* type; }; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class U> using rebind = U*; #endif static T* pointer_to(typename detail::ptr_value<T>::type& v) BOOST_NOEXCEPT { return boost::addressof(v); } }; #endif template<class T> BOOST_CONSTEXPR inline T* to_address(T* v) BOOST_NOEXCEPT { return v; } #if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION) namespace detail { template<class T> inline T* ptr_address(T* v, int) BOOST_NOEXCEPT { return v; } template<class T> inline auto ptr_address(const T& v, int) BOOST_NOEXCEPT -> decltype(boost::pointer_traits<T>::to_address(v)) { return boost::pointer_traits<T>::to_address(v); } template<class T> inline auto ptr_address(const T& v, long) BOOST_NOEXCEPT { return boost::detail::ptr_address(v.operator->(), 0); } } /* detail */ template<class T> inline auto to_address(const T& v) BOOST_NOEXCEPT { return boost::detail::ptr_address(v, 0); } #else template<class T> inline typename pointer_traits<T>::element_type* to_address(const T& v) BOOST_NOEXCEPT { return boost::to_address(v.operator->()); } #endif } /* boost */ #endif use_default.hpp 0000644 00000000454 15125235435 0007565 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_USE_DEFAULT_HPP #define BOOST_CORE_USE_DEFAULT_HPP namespace boost { struct use_default { }; } /* boost */ #endif first_scalar.hpp 0000644 00000001455 15125235435 0007743 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_FIRST_SCALAR_HPP #define BOOST_CORE_FIRST_SCALAR_HPP #include <boost/config.hpp> #include <cstddef> namespace boost { namespace detail { template<class T> struct make_scalar { typedef T type; }; template<class T, std::size_t N> struct make_scalar<T[N]> { typedef typename make_scalar<T>::type type; }; } /* detail */ template<class T> BOOST_CONSTEXPR inline T* first_scalar(T* p) BOOST_NOEXCEPT { return p; } template<class T, std::size_t N> BOOST_CONSTEXPR inline typename detail::make_scalar<T>::type* first_scalar(T (*p)[N]) BOOST_NOEXCEPT { return boost::first_scalar(&(*p)[0]); } } /* boost */ #endif addressof.hpp 0000644 00000014011 15125235435 0007231 0 ustar 00 /* Copyright (C) 2002 Brad King (brad.king@kitware.com) Douglas Gregor (gregod@cs.rpi.edu) Copyright (C) 2002, 2008, 2013 Peter Dimov Copyright (C) 2017 Glen Joseph Fernandes (glenjofe@gmail.com) 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_CORE_ADDRESSOF_HPP #define BOOST_CORE_ADDRESSOF_HPP #include <boost/config.hpp> #if defined(BOOST_MSVC_FULL_VER) && BOOST_MSVC_FULL_VER >= 190024215 #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF #elif defined(BOOST_GCC) && BOOST_GCC >= 70000 #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF #elif defined(__has_builtin) #if __has_builtin(__builtin_addressof) #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF #endif #endif #if defined(BOOST_CORE_HAS_BUILTIN_ADDRESSOF) #if defined(BOOST_NO_CXX11_CONSTEXPR) #define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF #endif namespace boost { template<class T> BOOST_CONSTEXPR inline T* addressof(T& o) BOOST_NOEXCEPT { return __builtin_addressof(o); } } /* boost */ #else #include <boost/config/workaround.hpp> #include <cstddef> namespace boost { namespace detail { template<class T> class addrof_ref { public: BOOST_FORCEINLINE addrof_ref(T& o) BOOST_NOEXCEPT : o_(o) { } BOOST_FORCEINLINE operator T&() const BOOST_NOEXCEPT { return o_; } private: addrof_ref& operator=(const addrof_ref&); T& o_; }; template<class T> struct addrof { static BOOST_FORCEINLINE T* get(T& o, long) BOOST_NOEXCEPT { return reinterpret_cast<T*>(& const_cast<char&>(reinterpret_cast<const volatile char&>(o))); } static BOOST_FORCEINLINE T* get(T* p, int) BOOST_NOEXCEPT { return p; } }; #if !defined(BOOST_NO_CXX11_NULLPTR) #if !defined(BOOST_NO_CXX11_DECLTYPE) && \ (defined(__INTEL_COMPILER) || \ (defined(__clang__) && !defined(_LIBCPP_VERSION))) typedef decltype(nullptr) addrof_null_t; #else typedef std::nullptr_t addrof_null_t; #endif template<> struct addrof<addrof_null_t> { typedef addrof_null_t type; static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT { return &o; } }; template<> struct addrof<const addrof_null_t> { typedef const addrof_null_t type; static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT { return &o; } }; template<> struct addrof<volatile addrof_null_t> { typedef volatile addrof_null_t type; static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT { return &o; } }; template<> struct addrof<const volatile addrof_null_t> { typedef const volatile addrof_null_t type; static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT { return &o; } }; #endif } /* detail */ #if defined(BOOST_NO_CXX11_SFINAE_EXPR) || \ defined(BOOST_NO_CXX11_CONSTEXPR) || \ defined(BOOST_NO_CXX11_DECLTYPE) #define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF template<class T> BOOST_FORCEINLINE T* addressof(T& o) BOOST_NOEXCEPT { #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \ BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120) return boost::detail::addrof<T>::get(o, 0); #else return boost::detail::addrof<T>::get(boost::detail::addrof_ref<T>(o), 0); #endif } #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) namespace detail { template<class T> struct addrof_result { typedef T* type; }; } /* detail */ template<class T, std::size_t N> BOOST_FORCEINLINE typename boost::detail::addrof_result<T[N]>::type addressof(T (&o)[N]) BOOST_NOEXCEPT { return &o; } #endif #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) template<class T, std::size_t N> BOOST_FORCEINLINE T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N] { return reinterpret_cast<T(*)[N]>(&o); } template<class T, std::size_t N> BOOST_FORCEINLINE const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N] { return reinterpret_cast<const T(*)[N]>(&o); } #endif #else namespace detail { template<class T> T addrof_declval() BOOST_NOEXCEPT; template<class> struct addrof_void { typedef void type; }; template<class T, class E = void> struct addrof_member_operator { static constexpr bool value = false; }; template<class T> struct addrof_member_operator<T, typename addrof_void<decltype(addrof_declval<T&>().operator&())>::type> { static constexpr bool value = true; }; #if BOOST_WORKAROUND(BOOST_INTEL, < 1600) struct addrof_addressable { }; addrof_addressable* operator&(addrof_addressable&) BOOST_NOEXCEPT; #endif template<class T, class E = void> struct addrof_non_member_operator { static constexpr bool value = false; }; template<class T> struct addrof_non_member_operator<T, typename addrof_void<decltype(operator&(addrof_declval<T&>()))>::type> { static constexpr bool value = true; }; template<class T, class E = void> struct addrof_expression { static constexpr bool value = false; }; template<class T> struct addrof_expression<T, typename addrof_void<decltype(&addrof_declval<T&>())>::type> { static constexpr bool value = true; }; template<class T> struct addrof_is_constexpr { static constexpr bool value = addrof_expression<T>::value && !addrof_member_operator<T>::value && !addrof_non_member_operator<T>::value; }; template<bool E, class T> struct addrof_if { }; template<class T> struct addrof_if<true, T> { typedef T* type; }; template<class T> BOOST_FORCEINLINE typename addrof_if<!addrof_is_constexpr<T>::value, T>::type addressof(T& o) BOOST_NOEXCEPT { return addrof<T>::get(addrof_ref<T>(o), 0); } template<class T> constexpr BOOST_FORCEINLINE typename addrof_if<addrof_is_constexpr<T>::value, T>::type addressof(T& o) BOOST_NOEXCEPT { return &o; } } /* detail */ template<class T> constexpr BOOST_FORCEINLINE T* addressof(T& o) BOOST_NOEXCEPT { return boost::detail::addressof(o); } #endif } /* boost */ #endif #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \ !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) namespace boost { template<class T> const T* addressof(const T&&) = delete; } /* boost */ #endif #endif checked_delete.hpp 0000644 00000003215 15125235435 0010173 0 ustar 00 #ifndef BOOST_CORE_CHECKED_DELETE_HPP #define BOOST_CORE_CHECKED_DELETE_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include <boost/config.hpp> // // boost/checked_delete.hpp // // Copyright (c) 2002, 2003 Peter Dimov // Copyright (c) 2003 Daniel Frey // Copyright (c) 2003 Howard Hinnant // // 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/core/doc/html/core/checked_delete.html for documentation. // namespace boost { // verify that types are complete for increased safety template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT { // intentionally complex - simplification causes regressions typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; (void) sizeof(type_must_be_complete); delete x; } template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT { typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; (void) sizeof(type_must_be_complete); delete [] x; } template<class T> struct checked_deleter { typedef void result_type; typedef T * argument_type; void operator()(T * x) const BOOST_NOEXCEPT { // boost:: disables ADL boost::checked_delete(x); } }; template<class T> struct checked_array_deleter { typedef void result_type; typedef T * argument_type; void operator()(T * x) const BOOST_NOEXCEPT { boost::checked_array_delete(x); } }; } // namespace boost #endif // #ifndef BOOST_CORE_CHECKED_DELETE_HPP explicit_operator_bool.hpp 0000644 00000012352 15125235435 0012034 0 ustar 00 /* * Copyright Andrey Semashev 2007 - 2013. * 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) */ /*! * \file explicit_operator_bool.hpp * \author Andrey Semashev * \date 08.03.2009 * * This header defines a compatibility macro that implements an unspecified * \c bool operator idiom, which is superseded with explicit conversion operators in * C++11. */ #ifndef BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP #define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP #include <boost/config.hpp> #include <boost/config/workaround.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif #if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) /*! * \brief The macro defines an explicit operator of conversion to \c bool * * The macro should be used inside the definition of a class that has to * support the conversion. The class should also implement <tt>operator!</tt>, * in terms of which the conversion operator will be implemented. */ #define BOOST_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE explicit operator bool () const\ {\ return !this->operator! ();\ } /*! * \brief The macro defines a noexcept explicit operator of conversion to \c bool * * The macro should be used inside the definition of a class that has to * support the conversion. The class should also implement <tt>operator!</tt>, * in terms of which the conversion operator will be implemented. */ #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ BOOST_FORCEINLINE explicit operator bool () const BOOST_NOEXCEPT\ {\ return !this->operator! ();\ } #if !BOOST_WORKAROUND(BOOST_GCC, < 40700) /*! * \brief The macro defines a constexpr explicit operator of conversion to \c bool * * The macro should be used inside the definition of a class that has to * support the conversion. The class should also implement <tt>operator!</tt>, * in terms of which the conversion operator will be implemented. */ #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE BOOST_CONSTEXPR explicit operator bool () const BOOST_NOEXCEPT\ {\ return !this->operator! ();\ } #else #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL() BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() #endif #else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) #if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG) // Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it #define BOOST_NO_UNSPECIFIED_BOOL #endif // (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG) #if !defined(BOOST_NO_UNSPECIFIED_BOOL) namespace boost { namespace detail { #if !defined(_MSC_VER) && !defined(__IBMCPP__) struct unspecified_bool { // NOTE TO THE USER: If you see this in error messages then you tried // to apply an unsupported operator on the object that supports // explicit conversion to bool. struct OPERATORS_NOT_ALLOWED; static void true_value(OPERATORS_NOT_ALLOWED*) {} }; typedef void (*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*); #else // MSVC and VACPP are too eager to convert pointer to function to void* even though they shouldn't struct unspecified_bool { // NOTE TO THE USER: If you see this in error messages then you tried // to apply an unsupported operator on the object that supports // explicit conversion to bool. struct OPERATORS_NOT_ALLOWED; void true_value(OPERATORS_NOT_ALLOWED*) {} }; typedef void (unspecified_bool::*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*); #endif } // namespace detail } // namespace boost #define BOOST_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const\ {\ return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ } #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\ {\ return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ } #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE BOOST_CONSTEXPR operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\ {\ return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ } #else // !defined(BOOST_NO_UNSPECIFIED_BOOL) #define BOOST_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE operator bool () const\ {\ return !this->operator! ();\ } #define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ BOOST_FORCEINLINE operator bool () const BOOST_NOEXCEPT\ {\ return !this->operator! ();\ } #define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ BOOST_FORCEINLINE BOOST_CONSTEXPR operator bool () const BOOST_NOEXCEPT\ {\ return !this->operator! ();\ } #endif // !defined(BOOST_NO_UNSPECIFIED_BOOL) #endif // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) #endif // BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP noinit_adaptor.hpp 0000644 00000003377 15125235435 0010306 0 ustar 00 /* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP #define BOOST_CORE_NOINIT_ADAPTOR_HPP #include <boost/core/allocator_access.hpp> namespace boost { template<class A> struct noinit_adaptor : A { template<class U> struct rebind { typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other; }; noinit_adaptor() : A() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template<class U> noinit_adaptor(U&& u) BOOST_NOEXCEPT : A(std::forward<U>(u)) { } #else template<class U> noinit_adaptor(const U& u) BOOST_NOEXCEPT : A(u) { } template<class U> noinit_adaptor(U& u) BOOST_NOEXCEPT : A(u) { } #endif template<class U> noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT : A(static_cast<const A&>(u)) { } template<class U> void construct(U* p) { ::new((void*)p) U; } #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class U, class V> void construct(U* p, const V& v) { ::new((void*)p) U(v); } #endif template<class U> void destroy(U* p) { p->~U(); } }; template<class T, class U> inline bool operator==(const noinit_adaptor<T>& lhs, const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT { return static_cast<const T&>(lhs) == static_cast<const U&>(rhs); } template<class T, class U> inline bool operator!=(const noinit_adaptor<T>& lhs, const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT { return !(lhs == rhs); } template<class A> inline noinit_adaptor<A> noinit_adapt(const A& a) BOOST_NOEXCEPT { return noinit_adaptor<A>(a); } } /* boost */ #endif uncaught_exceptions.hpp 0000644 00000015243 15125235435 0011346 0 ustar 00 /* * Copyright Andrey Semashev 2018 - 2020. * 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) */ /*! * \file uncaught_exceptions.hpp * \author Andrey Semashev * \date 2018-11-10 * * \brief This header provides an `uncaught_exceptions` function implementation, which was introduced in C++17. * * The code in this file is based on the implementation by Evgeny Panasyuk: * * https://github.com/panaseleus/stack_unwinding/blob/master/boost/exception/uncaught_exception_count.hpp */ #ifndef BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_ #define BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_ #include <exception> #include <boost/config.hpp> #if defined(BOOST_HAS_PRAGMA_ONCE) #pragma once #endif #if defined(__APPLE__) #include <Availability.h> // Apple systems only support std::uncaught_exceptions starting with specific versions: // - Mac OS >= 10.12 // - iOS >= 10.0 // - tvOS >= 10.0 // - watchOS >= 3.0 // https://github.com/boostorg/core/issues/80 #if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) && \ ( \ (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) \ ) #define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS #endif // Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions #elif (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \ (defined(_MSC_VER) && _MSC_VER >= 1900) #define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS #endif #if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) // cxxabi.h availability macro #if defined(__has_include) && (!defined(BOOST_GCC) || (__GNUC__ >= 5)) # if __has_include(<cxxabi.h>) # define BOOST_CORE_HAS_CXXABI_H # endif #elif defined(__GLIBCXX__) || defined(__GLIBCPP__) # define BOOST_CORE_HAS_CXXABI_H #endif #if defined(BOOST_CORE_HAS_CXXABI_H) // MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0. // Just disable it for now and fall back to std::uncaught_exception(). // On AIX, xlclang++ does have cxxabi.h but doesn't have __cxa_get_globals (https://github.com/boostorg/core/issues/78). #if !( \ (defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) || \ defined(__ibmxl__) \ ) #include <cxxabi.h> #include <cstring> #define BOOST_CORE_HAS_CXA_GET_GLOBALS // At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() in cxxabi.h. Older versions of GCC do not expose this function but it's there. // On OpenBSD, it seems, the declaration is also missing. // Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with a different exception specification, so we can't declare the function unconditionally. // On Linux with clang and libc++ and on OS X, there is a version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, but provides __cxa_uncaught_exceptions. // The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the library. Unfortunately, there are linking errors about undefined reference to __cxa_uncaught_exceptions // on Ubuntu Trusty and OS X, so we avoid using it and forward-declare __cxa_get_globals instead. // On QNX SDP 7.0 (QCC 5.4.0), there are multiple cxxabi.h, one from glibcxx from gcc and another from libc++abi from LLVM. Which one is included will be determined by the qcc // command line arguments (-V and/or -Y; http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html). The LLVM libc++abi is missing the declaration // of __cxa_get_globals but it is also patched by QNX developers to not define _LIBCPPABI_VERSION. Older QNX SDP versions, up to and including 6.6, don't provide LLVM and libc++abi. // See https://github.com/boostorg/core/issues/59. #if !defined(__FreeBSD__) && \ ( \ (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \ defined(__OpenBSD__) || \ (defined(__QNXNTO__) && !defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || \ defined(_LIBCPPABI_VERSION) \ ) namespace __cxxabiv1 { struct __cxa_eh_globals; #if defined(__OpenBSD__) extern "C" __cxa_eh_globals* __cxa_get_globals(); #else extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __attribute__((__const__)); #endif } // namespace __cxxabiv1 #endif #endif #endif // defined(BOOST_CORE_HAS_CXXABI_H) #if defined(_MSC_VER) && _MSC_VER >= 1400 #include <cstring> #define BOOST_CORE_HAS_GETPTD namespace boost { namespace core { namespace detail { extern "C" void* _getptd(); } // namespace detail } // namespace core } // namespace boost #endif // defined(_MSC_VER) && _MSC_VER >= 1400 #endif // !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) #if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) && !defined(BOOST_CORE_HAS_CXA_GET_GLOBALS) && !defined(BOOST_CORE_HAS_GETPTD) //! This macro is defined when `uncaught_exceptions` is not guaranteed to return values greater than 1 if multiple exceptions are pending #define BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED #endif namespace boost { namespace core { //! Returns the number of currently pending exceptions inline unsigned int uncaught_exceptions() BOOST_NOEXCEPT { #if defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) // C++17 implementation return static_cast< unsigned int >(std::uncaught_exceptions()); #elif defined(BOOST_CORE_HAS_CXA_GET_GLOBALS) // Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64} unsigned int count; std::memcpy(&count, reinterpret_cast< const unsigned char* >(::abi::__cxa_get_globals()) + sizeof(void*), sizeof(count)); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8 return count; #elif defined(BOOST_CORE_HAS_GETPTD) // MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}. unsigned int count; std::memcpy(&count, static_cast< const unsigned char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8u ? 0x100 : 0x90), sizeof(count)); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100 return count; #else // Portable C++03 implementation. Does not allow to detect multiple nested exceptions. return static_cast< unsigned int >(std::uncaught_exception()); #endif } } // namespace core } // namespace boost #undef BOOST_CORE_HAS_CXXABI_H #undef BOOST_CORE_HAS_CXA_GET_GLOBALS #undef BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS #undef BOOST_CORE_HAS_GETPTD #endif // BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_ demangle.hpp 0000644 00000005732 15125235435 0007045 0 ustar 00 #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED #define BOOST_CORE_DEMANGLE_HPP_INCLUDED // core::demangle // // Copyright 2014 Peter Dimov // Copyright 2014 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include <boost/config.hpp> #include <string> #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif // __has_include is currently supported by GCC and Clang. However GCC 4.9 may have issues and // returns 1 for 'defined( __has_include )', while '__has_include' is actually not supported: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63662 #if defined( __has_include ) && (!defined( BOOST_GCC ) || (__GNUC__ + 0) >= 5) # if __has_include(<cxxabi.h>) # define BOOST_CORE_HAS_CXXABI_H # endif #elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ ) # define BOOST_CORE_HAS_CXXABI_H #endif #if defined( BOOST_CORE_HAS_CXXABI_H ) # include <cxxabi.h> // For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library // (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement // abi::__cxa_demangle(). We detect this implementation by checking the include guard here. # if defined( __GABIXX_CXXABI_H__ ) # undef BOOST_CORE_HAS_CXXABI_H # else # include <cstdlib> # include <cstddef> # endif #endif namespace boost { namespace core { inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT; inline void demangle_free( char const * name ) BOOST_NOEXCEPT; class scoped_demangled_name { private: char const * m_p; public: explicit scoped_demangled_name( char const * name ) BOOST_NOEXCEPT : m_p( demangle_alloc( name ) ) { } ~scoped_demangled_name() BOOST_NOEXCEPT { demangle_free( m_p ); } char const * get() const BOOST_NOEXCEPT { return m_p; } BOOST_DELETED_FUNCTION(scoped_demangled_name( scoped_demangled_name const& )) BOOST_DELETED_FUNCTION(scoped_demangled_name& operator= ( scoped_demangled_name const& )) }; #if defined( BOOST_CORE_HAS_CXXABI_H ) inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT { int status = 0; std::size_t size = 0; return abi::__cxa_demangle( name, NULL, &size, &status ); } inline void demangle_free( char const * name ) BOOST_NOEXCEPT { std::free( const_cast< char* >( name ) ); } inline std::string demangle( char const * name ) { scoped_demangled_name demangled_name( name ); char const * p = demangled_name.get(); if( !p ) p = name; return p; } #else inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT { return name; } inline void demangle_free( char const * ) BOOST_NOEXCEPT { } inline std::string demangle( char const * name ) { return name; } #endif } // namespace core } // namespace boost #undef BOOST_CORE_HAS_CXXABI_H #endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED no_exceptions_support.hpp 0000644 00000003520 15125235435 0011733 0 ustar 00 #ifndef BOOST_CORE_NO_EXCEPTIONS_SUPPORT_HPP #define BOOST_CORE_NO_EXCEPTIONS_SUPPORT_HPP #if defined(_MSC_VER) # pragma once #endif //---------------------------------------------------------------------- // (C) Copyright 2004 Pavel Vozenilek. // 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) // // // This file contains helper macros used when exception support may be // disabled (as indicated by macro BOOST_NO_EXCEPTIONS). // // Before picking up these macros you may consider using RAII techniques // to deal with exceptions - their syntax can be always the same with // or without exception support enabled. //---------------------------------------------------------------------- #include <boost/config.hpp> #include <boost/config/workaround.hpp> #if !(defined BOOST_NO_EXCEPTIONS) # define BOOST_TRY { try # define BOOST_CATCH(x) catch(x) # define BOOST_RETHROW throw; # define BOOST_CATCH_END } #else # if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) # define BOOST_TRY { if ("") # define BOOST_CATCH(x) else if (!"") # elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900 # define BOOST_TRY { if (true) # define BOOST_CATCH(x) else if (false) # else // warning C4127: conditional expression is constant # define BOOST_TRY { \ __pragma(warning(push)) \ __pragma(warning(disable: 4127)) \ if (true) \ __pragma(warning(pop)) # define BOOST_CATCH(x) else \ __pragma(warning(push)) \ __pragma(warning(disable: 4127)) \ if (false) \ __pragma(warning(pop)) # endif # define BOOST_RETHROW # define BOOST_CATCH_END } #endif #endif underlying_type.hpp 0000644 00000004235 15125235435 0010507 0 ustar 00 // underlying_type.hpp ---------------------------------------------------------// // Copyright Beman Dawes, 2009 // Copyright (C) 2011-2012 Vicente J. Botet Escriba // Copyright (C) 2012 Anthony Williams // Copyright (C) 2014 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt #ifndef BOOST_CORE_UNDERLYING_TYPE_HPP #define BOOST_CORE_UNDERLYING_TYPE_HPP #include <boost/config.hpp> // GCC 4.7 and later seem to provide std::underlying_type #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) || (defined(BOOST_GCC) && BOOST_GCC >= 40700 && defined(__GXX_EXPERIMENTAL_CXX0X__)) #include <type_traits> #define BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE #endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { namespace detail { template< typename EnumType, typename Void = void > struct underlying_type_impl; #if defined(BOOST_NO_CXX11_SCOPED_ENUMS) // Support for boost/core/scoped_enum.hpp template< typename EnumType > struct underlying_type_impl< EnumType, typename EnumType::is_boost_scoped_enum_tag > { /** * The member typedef type names the underlying type of EnumType. It is EnumType::underlying_type when the EnumType is an emulated scoped enum, */ typedef typename EnumType::underlying_type type; }; #endif #if defined(BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE) template< typename EnumType, typename Void > struct underlying_type_impl { typedef typename std::underlying_type< EnumType >::type type; }; #endif } // namespace detail #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE) #define BOOST_NO_UNDERLYING_TYPE #endif /** * Meta-function to get the underlying type of a scoped enum. * * Requires EnumType must be an enum type or the emulation of a scoped enum. * If BOOST_NO_UNDERLYING_TYPE is defined, the implementation will not be able * to deduce the underlying type of enums. The user is expected to specialize * this trait in this case. */ template< typename EnumType > struct underlying_type : public detail::underlying_type_impl< EnumType > { }; } // namespace boost #endif // BOOST_CORE_UNDERLYING_TYPE_HPP check_macro.hpp 0000644 00000011727 15125714652 0007533 0 ustar 00 #ifndef BOOST_CONTRACT_CHECK_MACRO_HPP_ #define BOOST_CONTRACT_CHECK_MACRO_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Macros for implementation checks. */ // IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. #include <boost/contract/core/config.hpp> #include <boost/contract/detail/noop.hpp> #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Preferred way to assert implementation check conditions. It is preferred to use this macro instead of programming implementation checks in a nullary functor passed to @RefClass{boost::contract::check} constructor because this macro will completely remove implementation checks from the code when @RefMacro{BOOST_CONTRACT_NO_CHECKS} is defined: @code void f() { ... BOOST_CONTRACT_CHECK(cond); ... } @endcode @RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and @RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels predefined by this library for implementation checks. @see @RefSect{advanced.implementation_checks, Implementation Checks} @param cond Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and @c BOOST_CONTRACT_CHECK((cond)) will always work.) */ #define BOOST_CONTRACT_CHECK(cond) #elif !defined(BOOST_CONTRACT_NO_CHECKS) #include <boost/contract/detail/check.hpp> #include <boost/contract/detail/assert.hpp> #define BOOST_CONTRACT_CHECK(cond) \ BOOST_CONTRACT_DETAIL_CHECK(BOOST_CONTRACT_DETAIL_ASSERT(cond)) #else #define BOOST_CONTRACT_CHECK(cond) /* nothing */ #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Preferred way to assert implementation check conditions that are computationally expensive, at least compared to the computational cost of executing the function body. The specified condition will always be compiled and validated syntactically, but it will not be checked at run-time unless @RefMacro{BOOST_CONTRACT_AUDITS} is defined (undefined by default). This macro is defined by code equivalent to: @code #ifdef BOOST_CONTRACT_AUDITS #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ BOOST_CONTRACT_CHECK(cond) #else #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ BOOST_CONTRACT_CHECK(true || cond) #endif @endcode @RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and @RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels predefined by this library for implementation checks. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above. @see @RefSect{extras.assertion_levels, Assertion Levels} @param cond Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and @c BOOST_CONTRACT_CHECK_AUDIT((cond)) will always work.) */ #define BOOST_CONTRACT_CHECK_AUDIT(cond) #elif defined(BOOST_CONTRACT_AUDITS) #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ BOOST_CONTRACT_CHECK(cond) #else #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ BOOST_CONTRACT_DETAIL_NOEVAL(cond) #endif /** Preferred way to document in the code implementation check conditions that are computationally prohibitive, at least compared to the computational cost of executing the function body. The specified condition will always be compiled and validated syntactically, but it will never be checked at run-time. This macro is defined by code equivalent to: @code #define BOOST_CONTRACT_CHECK_AXIOM(cond) \ BOOST_CONTRACT_CHECK(true || cond) @endcode @RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and @RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels predefined by this library for implementation checks. If there is a need, programmers are free to implement their own assertion levels defining macros similar to the one above. @see @RefSect{extras.assertion_levels, Assertion Levels} @param cond Boolean condition to check within implementation code (function body, etc.). (This is not a variadic macro parameter so any comma it might contain must be protected by round parenthesis and @c BOOST_CONTRACT_CHECK_AXIOM((cond)) will always work.) */ #define BOOST_CONTRACT_CHECK_AXIOM(cond) \ BOOST_CONTRACT_DETAIL_NOEVAL(cond) #endif // #include guard config.hpp 0000644 00000103214 15125714652 0006533 0 ustar 00 #ifndef BOOST_CONTRACT_CONFIG_HPP_ #define BOOST_CONTRACT_CONFIG_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Configure this library compile-time and run-time behaviours. */ // IMPORTANT: This header MUST NOT #include any other header of this lib. // That way users can #include this header and not #include any of this lib // headers after that depending on the contract 0/1 macros below ensuring no // compilation overhead. // Export symbols when compiling as shared lib (for internal use only). (Named // after similar macros in all Boost libs.) // BOOST_CONTRACT_SOURCE // Disable automatic library selection for linking. (Named after similar macros // in all Boost libs.) // BOOST_CONTRACT_NO_LIB // BOOST_ALL_NO_LIB #if (!defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_ALL_DYN_LINK)) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) /** Define this macro to compile this library as a shared library (recommended). If this macro is defined, this library is compiled so it can be linked as a shared library (a.k.a., Dynamically Linked Library or DLL) to user code. This library will automatically define this macro when Boost libraries are built as shared libraries (e.g., defining @c BOOST_ALL_DYN_LINK or using <c>bjam link=shared ...</c>). @warning In general this library will correctly check contracts at run-time only when compiled as a shared library, unless user code checks contracts in a single program unit (e.g., a single program with only statically linked libraries). Therefore, it is recommended to build and use this library as a shared library by defining this macro (or equivalently by building all Boost libraries as shared libraries). @see @RefSect{getting_started, Getting Started} */ #define BOOST_CONTRACT_DYN_LINK #elif defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_CONTRACT_STATIC_LINK) #error "DYN_LINK defined with STATIC_LINK" #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Define this macro to compile this library as a static library (not recommended). If this macro is defined, this library is compiled so it can be linked statically to user code. This library will automatically define this macro when Boost libraries are built as static libraries. @warning This library is not guaranteed to always work correctly at run-time when this macro is defined (define @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK instead). However, this macro can be defined and this library can be safely used as a static library for user code that checks contracts in a single program unit (e.g., a single program with only statically linked libraries). @see @RefSect{getting_started, Getting Started} */ #define BOOST_CONTRACT_STATIC_LINK #elif defined(BOOST_CONTRACT_STATIC_LINK) && defined(BOOST_CONTRACT_DYN_LINK) #error "STATIC_LINK defined with DYN_LINK" #endif #ifdef BOOST_CONTRACT_HEADER_ONLY #error "leave DYN_LINK and STATIC_LINK undefined instead" #elif (!defined(BOOST_CONTRACT_DYN_LINK) && \ !defined(BOOST_CONTRACT_STATIC_LINK)) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) /** Automatically defined by this library when it is being used as a header-only library (not recommended). This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users do not define @RefMacro{BOOST_CONTRACT_DYN_LINK} (or @c BOOST_ALL_DYN_LINK) and @RefMacro{BOOST_CONTRACT_STATIC_LINK}. When used as a header-only library, this library code does not have to be compiled separately from user code, this library headers are simply included and compiled as part of the user program. @warning This library is not guaranteed to always work correctly at run-time when this macro is defined (define @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK instead). However, this macro can be defined and this library can be safely used as a header-only library for user code that checks contracts in a single program unit (e.g., a single program with only statically linked libraries). @see @RefSect{getting_started, Getting Started} */ #define BOOST_CONTRACT_HEADER_ONLY #endif #if (!defined(BOOST_CONTRACT_DISABLE_THREADS) && \ defined(BOOST_DISABLE_THREADS)) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) /** Define this macro to not lock internal library data for thread safety (undefined by default). Defining this macro will make the library implementation code not thread safe so this macro should not be defined unless the library is being used by single-threaded applications only. This library will automatically define this macro when Boost libraries are built without threads (e.g., defining @c BOOST_DISABLE_THREADS). @note When this macro is left undefined this library needs to internally use some sort of global lock (to ensure contract checking is globally disabled when other contracts are being checked and also to safely access failure handler functors). That could introduce an undesired amount of synchronization in some multi-threaded applications. @see @RefSect{contract_programming_overview.assertions, Assertions} */ #define BOOST_CONTRACT_DISABLE_THREADS #endif #ifndef BOOST_CONTRACT_MAX_ARGS /** Maximum number of arguments for public function overrides on compilers that do not support variadic templates (default to @c 10). On compilers that do not support C++11 variadic templates, this macro is defined to the maximum number of arguments that public function overrides can have and pass to @RefFunc{boost::contract::public_function} (users can redefine this macro to a different value). On compilers that support variadic templates, this macro has no effect. @note Regardless of the value of this macro and of compiler support for variadic templates, there might be an intrinsic limit of about 18 arguments for public function overrides (because of similar limits in Boost.MPL and Boost.FunctionTypes internally used by this library). @see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} */ #define BOOST_CONTRACT_MAX_ARGS 10 #endif #ifndef BOOST_CONTRACT_BASES_TYPEDEF /** Define the name of the base type @c typedef (@c base_types by default). This macro expands to the name of the @c typedef that lists the base classes for subcontracting via @RefMacro{BOOST_CONTRACT_BASE_TYPES}: @code class u #define BASES public b, private w : BASES { friend class boost::contract:access; typedef BOOST_CONTRACT_BASE_TYPES(BASES) BOOST_CONTRACT_TYPEDEF; #undef BASES ... }; @endcode When used this way, users can redefine this macro if the @c typedef must have a name different from @c base_types (because of name clashes in user code, etc.). @see @RefSect{tutorial.base_classes__subcontracting_, Base Classes} */ #define BOOST_CONTRACT_BASES_TYPEDEF base_types #endif #ifndef BOOST_CONTRACT_INVARIANT_FUNC /** Define the name of the class invariant member function (@c invariant by default). This macro expands to the name of the @c const and <c>const volatile</c> member functions that check class invariants and volatile class invariants respectively: @code class u { friend class boost::contract::access; void BOOST_CONTRACT_INVARIANT_FUNC() const { BOOST_CONTRACT_ASSERT(...); ... } void BOOST_CONTRACT_INVARIANT_FUNC() const volatile { BOOST_CONTRACT_ASSERT(...); ... } ... }; @endcode When used this way, users can redefine this macro if the invariant functions must have a name different from @c invariant (because of name clashes in user code, etc.). @note C++ does not allow to overload member functions based on the @c static classifier, so this macro must always be defined to be different than the function name defined for @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT_FUNC}. @see @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ #define BOOST_CONTRACT_INVARIANT_FUNC invariant #endif #ifndef BOOST_CONTRACT_STATIC_INVARIANT_FUNC /** Define the name of the static invariant member function (@c static_invariant by default). This macro expands to the name of the @c static member function that checks static class invariants: @code class u { friend class boost::contract::access; static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() { BOOST_CONTRACT_ASSERT(...); ... } ... }; @endcode When used this way, users can redefine this macro if the static invariant function must have a name different from @c static_invariant (because of name clashes in user code, etc.). @note C++ does not allow to overload member functions based on the @c static classifier, so this macro must always be defined to be different than the function name defined for @RefMacro{BOOST_CONTRACT_INVARIANT_FUNC}. @see @RefSect{tutorial.class_invariants, Class Invariants} */ #define BOOST_CONTRACT_STATIC_INVARIANT_FUNC static_invariant #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Disable some compile-time errors generated by this library (undefined by default). Defining this macro disables a number of static checks and related compile-time errors generated by this library, for example: @li The static invariant member function named as @c BOOST_CONTRACT_STATIC_INVARIANT_FUNC must be declared @c static. @li Non-static invariant member functions named as @c BOOST_CONTRACT_INVARIANT_FUNC must be declared either @c const, <c>const volatile</c>, or <c>volatile const</c>. @li Derived classes that program contracts for one or more public function overrides via @RefFunc{boost::contract::public_function} must also define the @RefMacro{BOOST_CONTRACT_BASE_TYPES} @c typedef. In general, it is not recommended to define this macro because these compile-time checks can guard against misuses of this library. @see @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{tutorial.base_classes__subcontracting_, Base Classes} */ #define BOOST_CONTRACT_PERMISSIVE #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Code block to execute if contracts are not assigned to a @RefClass{boost::contract::check} variable (undefined and executes @c BOOST_ASSERT(false) by default). In general, there is a logic error in the program when contracts are not explicitly assigned to a local variable of type @RefClass{boost::contract::check} and without using C++11 @c auto declarations (because that is a misuse of this library). Therefore, by default (i.e., when this macro is not defined) this library calls <c>BOOST_ASSERT(false)</c> in those cases. If this macro is defined, this library will execute the code expanded by this macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer to throw an exception, etc.). This macro can also be defined to be any block of code (and use empty curly brackets @c {} to generate no error, not recommended), for example (on GCC): @code gcc -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }' ... @endcode @see @RefSect{tutorial, Tutorial} */ #define BOOST_CONTRACT_ON_MISSING_CHECK_DECL #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Define this macro to not disable other assertions while checking preconditions (undefined by default). Not disabling other assertions while checking preconditions can lead to infinite recursion in user code so by default this macro is not defined. However, the @RefSect{bibliography, [N1962]} proposal does not disable assertions while checking preconditions because arguments can reach the function body unchecked if assertions are disabled while checking preconditions (e.g., when these same functions bodies are called to check the preconditions in question). This macro can be defined to obtain the behaviour specified in @RefSect{bibliography, [N1962]} (at the risk of infinite recursion). @see @RefSect{contract_programming_overview.feature_summary, Feature Summary} */ #define BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Define this macro to not disable any assertion while checking other assertions (undefined by default). Not disabling assertions while checking other assertions can lead to infinite recursion in user code so by default this macro is not defined. (Defining this macro automatically implies that other assertion checking is disabled while checking preconditions as if @RefMacro{BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION} was also defined.) @see @RefSect{contract_programming_overview.feature_summary, Feature Summary} */ #define BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** Define this macro to evaluate and check audit assertions at run-time (undefined by default). Audit assertions and implementation checks programmed via @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT} and @RefMacro{BOOST_CONTRACT_CHECK_AUDIT} are always compiled and validated syntactically. However, they are not evaluated and checked at run-time unless this macro is defined (because these conditions can be computationally expensive, at least compared to the computational cost of executing the function body). @see @RefSect{extras.assertion_levels, Assertion Levels} */ #define BOOST_CONTRACT_AUDITS #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** If defined, this library disables implementation checks (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with implementation checks. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of implementation checks or use @RefMacro{BOOST_CONTRACT_CHECK} (recommended). @see @RefSect{advanced.implementation_checks, Implementation Checks}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_CHECKS #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** If defined, this library does not check preconditions (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking preconditions. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of preconditions or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{tutorial.preconditions, Preconditions}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_PRECONDITIONS #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** If defined, this library does not check postconditions (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking postconditions. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of postconditions or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). It is necessary to disable both postconditions and exception guarantees defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies (see @RefMacro{BOOST_CONTRACT_NO_OLDS}). @see @RefSect{tutorial.postconditions, Postconditions}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_POSTCONDITIONS #endif #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN /** If defined, this library does not check exception guarantees (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking exception guarantees. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of exception guarantees or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). It is necessary to disable both postconditions and exception guarantees defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies (see @RefMacro{BOOST_CONTRACT_NO_OLDS}). @see @RefSect{tutorial.exception_guarantees, Exception Guarantees}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_EXCEPTS #endif #if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \ ( \ !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_INVARIANTS) \ ) /** If defined, this library does not check class invariants at entry (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants at entry. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of entry class invariants or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). This macro is automatically defined when @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined. @see @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_ENTRY_INVARIANTS #endif #if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \ ( \ !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_INVARIANTS) \ ) /** If defined, this library does not check class invariants at exit (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants at exit. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of exit class invariants or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). This macro is automatically defined when @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined. @see @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_EXIT_INVARIANTS #endif #if !defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) /** If defined, this library does not check class invariants (undefined by default). If this macro is defined, this library internal code is also optimized to reduce compile-time (not just run-time) overhead associated with checking class invariants. In addition, users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of class invariants or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). Defining this macro is equivalent to defining both @RefMacro{BOOST_CONTRACT_NO_ENTRY_INVARIANTS} and @RefMacro{BOOST_CONTRACT_NO_EXIT_INVARIANTS}. @see @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.disable_contract_checking, Disable Contract Checking}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_INVARIANTS #endif #ifdef BOOST_CONTRACT_NO_OLDS #error "define NO_POSTCONDITIONS and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when old value copies are not to be performed. This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define both @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of old value copies or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{tutorial.old_values, Old Values}, @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_OLDS #endif // Ctor pre checked separately and outside RAII so not part of this #define. #ifdef BOOST_CONTRACT_NO_CONSTRUCTORS #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when contracts are not checked for constructors. This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of contracts for constructors or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @note Constructor preconditions are checked separately by @RefClass{boost::contract::constructor_precondition} so they are disabled by @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS} instead. @see @RefSect{tutorial.constructors, Constructors}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_CONSTRUCTORS #endif #ifdef BOOST_CONTRACT_NO_DESTRUCTORS #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when contracts are not checked for destructors. This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of contracts for destructors or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{tutorial.destructors, Destructors}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_DESTRUCTORS #endif #ifdef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when contracts are not checked for public functions. This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of contracts for public functions or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{tutorial.public_functions, Public Functions}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS #endif #ifdef BOOST_CONTRACT_NO_FUNCTIONS #error "define NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when contracts are not checked for non-member, private, or protected functions. This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of contracts for non-member, private and protected functions, or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). This macro is also used when contracts are not checked for private or protected functions, lambda functions, code blocks, loops, etc. @see @RefSect{tutorial.non_member_functions, Non-Member Functions}, @RefSect{advanced.private_and_protected_functions, Private and Protected Functions}, @RefSect{advanced.lambdas__loops__code_blocks__and__constexpr__, Lambdas\, Loops\, Code Blocks}, @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_FUNCTIONS #endif #ifdef BOOST_CONTRACT_NO_CONDITIONS #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) /** Automatically defined by this library when contracts are not checked for preconditions, postconditions, exceptions guarantees, and class invariants (excluding implementation checks). This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}. Users can manually program @c \#ifndef statements in their code using this macro to completely disable compilation of contracts within specifications (so excluding implementation checks which are contracts within implementations instead), or use the macros defined in @c boost/contract_macro.hpp (recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_CONDITIONS #endif #ifdef BOOST_CONTRACT_NO_ALL #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, NO_EXCEPTS, and NO_CHECKS instead" #elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ defined(BOOST_CONTRACT_NO_EXCEPTS) && \ defined(BOOST_CONTRACT_NO_CHECKS) /** Automatically defined by this library when contracts are not checked at all (neither for specifications nor for implementations). This macro is not a configuration macro and this library will generate a compile-time error if users try to define it directly. This library will automatically define this macro when users define all @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and @RefMacro{BOOST_CONTRACT_NO_CHECKS}. For example, users can manually program @c \#ifndef statements in their code using this macro to avoid including the @c boost/contract.hpp header all together: @code #include <boost/contract/core/config.hpp> #ifndef BOOST_CONTRACT_NO_ALL #include <boost/contract.hpp> #endif @endcode Or, use the @c boost/contract_macro.hpp header and related macros instead (because the @c boost/contract_macro.hpp header is already optimized to not include other headers from this library when contracts are not checked, but recommended only for applications where it is truly necessary to completely remove contract code compilation from production code). @see @RefSect{extras.disable_contract_compilation__macro_interface_, Disable Contract Compilation} */ #define BOOST_CONTRACT_NO_ALL #endif #endif // #include guard virtual.hpp 0000644 00000013235 15125714652 0006757 0 ustar 00 #ifndef BOOST_CONTRACT_VIRTUAL_HPP_ #define BOOST_CONTRACT_VIRTUAL_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Handle virtual public functions with contracts (for subcontracting). */ // IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. #include <boost/contract/core/config.hpp> #ifndef BOOST_CONTRACT_NO_CONDITIONS #include <boost/contract/detail/decl.hpp> #endif #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS #include <boost/any.hpp> #endif #ifndef BOOST_CONTRACT_NO_OLDS #include <boost/shared_ptr.hpp> #include <queue> #endif namespace boost { namespace contract { #ifndef BOOST_CONTRACT_NO_CONDITIONS namespace detail { BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, /* is_friend = */ 0, OO, RR, FF, CC, AArgs); } #endif /** Type of extra function parameter to handle contracts for virtual public functions (for subcontracting). Virtual public functions (and therefore also public function overrides) declaring contracts using this library must specify an extra function parameter at the very end of their parameter list. This parameter must be a pointer to this class and it must have default value @c 0 or @c nullptr (this extra parameter is often named @c v in this documentation, but any name can be used): @code class u { public: virtual void f(int x, boost::contract::virtual_* v = 0) { // Declare `v`. ... // Contract declaration (which will use `v`) and function body. } ... }; @endcode In practice this extra parameter does not alter the calling interface of the enclosing function declaring the contract because it is always the very last parameter and it has a default value (so it can always be omitted when users call the function). This extra parameter must be passed to @RefFunc{boost::contract::public_function}, @RefMacro{BOOST_CONTRACT_OLDOF}, and all other operations of this library that accept a pointer to @RefClass{boost::contract::virtual_}. A part from that, this class is not intended to be directly used by programmers (and that is why this class does not have any public member and it is not copyable). @see @RefSect{tutorial.virtual_public_functions, Virtual Public Functions}, @RefSect{tutorial.public_function_overrides__subcontracting_, Public Function Overrides} */ class virtual_ { // Non-copyable (see below) to avoid copy queue, stack, etc. /** @cond */ private: // No public API (so users cannot use it directly by mistake). // No boost::noncopyable to avoid its overhead when contracts disabled. virtual_(virtual_&); virtual_& operator=(virtual_&); #ifndef BOOST_CONTRACT_NO_CONDITIONS enum action_enum { // virtual_ always held/passed as ptr so nullptr used for user call. no_action, #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS check_entry_inv, #endif #ifndef BOOST_CONTRACT_NO_PRECONDITIONS check_pre, #endif #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS check_exit_inv, #endif #ifndef BOOST_CONTRACT_NO_OLDS // For outside .old(...). push_old_init_copy, // pop_old_init_copy as static function below. // For inside .old(...). call_old_ftor, push_old_ftor_copy, pop_old_ftor_copy, #endif #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS check_post, #endif #ifndef BOOST_CONTRACT_NO_EXCEPTS check_except, #endif }; #endif #ifndef BOOST_CONTRACT_NO_OLDS // Not just an enum value because the logical combination of two values. inline static bool pop_old_init_copy(action_enum a) { return #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS a == check_post #endif #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ !defined(BOOST_CONTRACT_NO_EXCEPTS) || #endif #ifndef BOOST_CONTRACT_NO_EXCEPTS a == check_except #endif ; } #endif #ifndef BOOST_CONTRACT_NO_CONDITIONS explicit virtual_(action_enum a) : action_(a) , failed_(false) #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS , result_type_name_() , result_optional_() #endif {} #endif #ifndef BOOST_CONTRACT_NO_CONDITIONS action_enum action_; bool failed_; #endif #ifndef BOOST_CONTRACT_NO_OLDS std::queue<boost::shared_ptr<void> > old_init_copies_; std::queue<boost::shared_ptr<void> > old_ftor_copies_; #endif #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS boost::any result_ptr_; // Result for virtual and overriding functions. char const* result_type_name_; bool result_optional_; #endif // Friends (used to limit library's public API). #ifndef BOOST_CONTRACT_NO_OLDS friend bool copy_old(virtual_*); friend class old_pointer; #endif #ifndef BOOST_CONTRACT_NO_CONDITIONS BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, /* is_friend = */ 1, OO, RR, FF, CC, AArgs); #endif /** @endcond */ }; } } // namespace #endif // #include guard specify.hpp 0000644 00000071036 15125714652 0006736 0 ustar 00 #ifndef BOOST_CONTRACT_SPECIFY_HPP_ #define BOOST_CONTRACT_SPECIFY_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Specify preconditions, old values copied at body, postconditions, and exception guarantees Preconditions, old values copied at body, postconditions, and exception guarantees are all optionals but, when they are specified, they need to be specified in that order. */ #include <boost/contract/core/config.hpp> #include <boost/contract/detail/decl.hpp> #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) #include <boost/contract/detail/condition/cond_base.hpp> #include <boost/contract/detail/condition/cond_post.hpp> #include <boost/contract/detail/auto_ptr.hpp> #include <boost/contract/detail/none.hpp> #endif #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ !defined(BOOST_CONTRACT_NO_EXCEPTS) #include <boost/contract/detail/debug.hpp> #endif #include <boost/config.hpp> // NOTE: No inheritance for faster run-times (macros to avoid duplicated code). /* PRIVATE */ /* @cond */ // NOTE: Private copy ops below will force compile-time error is `auto c = ...` // is used instead of `check c = ...` but only up to C++17. C++17 strong copy // elision on function return values prevents this lib from generating a // compile-time error in those cases, but the lib will still generate a run-time // error according with ON_MISSING_CHECK_DECL. Furthermore, on some C++98 // compilers, this private copy ctor gives a warning (because of lack of copy // optimization on those compilers), this warning can be ignored. #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) #define BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(class_type, cond_type) \ private: \ boost::contract::detail::auto_ptr<cond_type > cond_; \ explicit class_type(cond_type* cond) : cond_(cond) {} \ class_type(class_type const& other) : cond_(other.cond_) {} \ class_type& operator=(class_type const& other) { \ cond_ = other.cond_; \ return *this; \ } #define BOOST_CONTRACT_SPECIFY_COND_RELEASE_ cond_.release() #else #define BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(class_type, cond_type) \ private: \ class_type() {} \ class_type(class_type const&) {} \ class_type& operator=(class_type const&) { return *this; } #define BOOST_CONTRACT_SPECIFY_COND_RELEASE_ /* nothing */ #endif #ifndef BOOST_CONTRACT_NO_PRECONDITIONS #define BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ \ BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ cond_->set_pre(f); \ return specify_old_postcondition_except<VirtualResult>( \ BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #else #define BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ \ return specify_old_postcondition_except<VirtualResult>( \ BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #endif #ifndef BOOST_CONTRACT_NO_OLDS #define BOOST_CONTRACT_SPECIFY_OLD_IMPL_ \ BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ cond_->set_old(f); \ return specify_postcondition_except<VirtualResult>( \ BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #else #define BOOST_CONTRACT_SPECIFY_OLD_IMPL_ \ return specify_postcondition_except<VirtualResult>( \ BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #endif #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS #define BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ \ BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ cond_->set_post(f); \ return specify_except(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #else #define BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ \ return specify_except(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #endif #ifndef BOOST_CONTRACT_NO_EXCEPTS #define BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ \ BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ cond_->set_except(f); \ return specify_nothing(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #else #define BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ \ return specify_nothing(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); #endif /* @endcond */ /* CODE */ namespace boost { namespace contract { class virtual_; template<typename VR> class specify_precondition_old_postcondition_except; template<typename VR> class specify_old_postcondition_except; template<typename VR> class specify_postcondition_except; class specify_except; } } namespace boost { namespace contract { /** Used to prevent setting other contract conditions after exception guarantees. This class has no member function so it is used to prevent specifying additional functors to check any other contract. This object is internally constructed by the library when users specify contracts calling @RefFunc{boost::contract::function} and similar functions (that is why this class does not have a public constructor). @see @RefSect{tutorial, Tutorial} */ class specify_nothing { // Privately copyable (as *). public: /** Destruct this object. @b Throws: This is declared @c noexcept(false) since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}). */ ~specify_nothing() BOOST_NOEXCEPT_IF(false) {} // No set member function here. /** @cond */ private: BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(specify_nothing, boost::contract::detail::cond_base) // Friends (used to limit library's public API). friend class check; template<typename VR> friend class specify_precondition_old_postcondition_except; template<typename VR> friend class specify_old_postcondition_except; template<typename VR> friend class specify_postcondition_except; friend class specify_except; /** @endcond */ }; /** Allow to specify exception guarantees. Allow to specify the functor this library will call to check exception guarantees. This object is internally constructed by the library when users specify contracts calling @RefFunc{boost::contract::function} and similar functions (that is why this class does not have a public constructor). @see @RefSect{tutorial.exception_guarantees, Exception Guarantees} */ class specify_except { // Privately copyable (as *). public: /** Destruct this object. @b Throws: This is declared @c noexcept(false) since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}). */ ~specify_except() BOOST_NOEXCEPT_IF(false) {} /** Allow to specify exception guarantees. @param f Nullary functor called by this library to check exception guarantees @c f(). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::except_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). @return After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. */ template<typename F> specify_nothing except( F const& #if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ } /** @cond */ private: BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(specify_except, boost::contract::detail::cond_base) // Friends (used to limit library's public API). friend class check; template<typename VR> friend class specify_precondition_old_postcondition_except; template<typename VR> friend class specify_old_postcondition_except; template<typename VR> friend class specify_postcondition_except; /** @endcond */ }; /** Allow to specify postconditions or exception guarantees. Allow to specify functors this library will call to check postconditions or exception guarantees. This object is internally constructed by the library when users specify contracts calling @RefFunc{boost::contract::function} and similar functions (that is why this class does not have a public constructor). @see @RefSect{tutorial.postconditions, Postconditions}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} @tparam VirtualResult Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always @c void. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) */ template<typename VirtualResult = void> class specify_postcondition_except { // Privately copyable (as *). public: /** Destruct this object. @b Throws: This is declared @c noexcept(false) since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}). */ ~specify_postcondition_except() BOOST_NOEXCEPT_IF(false) {} /** Allow to specify postconditions. @param f Functor called by this library to check postconditions @c f() or @c f(result). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::postcondition_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). This functor must be a nullary functor @c f() if @c VirtualResult is @c void, otherwise it must be a unary functor @c f(result) accepting the return value @c result as a parameter of type <c>VirtualResult const&</c> (to avoid extra copies of the return value, or of type @c VirtualResult or <c>VirtualResult const</c> if extra copies of the return value are irrelevant). @return After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. */ template<typename F> specify_except postcondition( F const& #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ } /** Allow to specify exception guarantees. @param f Nullary functor called by this library to check exception guarantees @c f(). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::except_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). @return After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. */ template<typename F> specify_nothing except( F const& #if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ } /** @cond */ private: BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( specify_postcondition_except, boost::contract::detail::cond_post<typename boost::contract::detail::none_if_void<VirtualResult>::type> ) // Friends (used to limit library's public API). friend class check; friend class specify_precondition_old_postcondition_except<VirtualResult>; friend class specify_old_postcondition_except<VirtualResult>; /** @endcond */ }; /** Allow to specify old values copied at body, postconditions, and exception guarantees. Allow to specify functors this library will call to copy old values at body, check postconditions, and check exception guarantees. This object is internally constructed by the library when users specify contracts calling @RefFunc{boost::contract::function} and similar functions (that is why this class does not have a public constructor). @see @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}, @RefSect{tutorial.postconditions, Postconditions}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} @tparam VirtualResult Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always @c void. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) */ template<typename VirtualResult = void> class specify_old_postcondition_except { // Privately copyable (as *). public: /** Destruct this object. @b Throws: This is declared @c noexcept(false) since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}). */ ~specify_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {} /** Allow to specify old values copied at body. It should often be sufficient to initialize old value pointers as soon as they are declared, without using this function (see @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}). @param f Nullary functor called by this library @c f() to assign old value copies just before the body is executed but after entry invariants (when they apply) and preconditions are checked. Old value pointers within this functor call are usually assigned using @RefMacro{BOOST_CONTRACT_OLDOF}. Any exception thrown by a call to this functor will result in this library calling @RefFunc{boost::contract::old_failure} (because old values could not be copied to check postconditions and exception guarantees). This functor should capture old value pointers by references so they can be assigned (all other variables needed to evaluate old value expressions can be captured by (constant) value, or better by (constant) reference to avoid extra copies). @return After old values copied at body have been specified, the object returned by this function allows to optionally specify postconditions and exception guarantees. */ template<typename F> specify_postcondition_except<VirtualResult> old( F const& #if !defined(BOOST_CONTRACT_NO_OLDS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_OLD_IMPL_ } /** Allow to specify postconditions. @param f Functor called by this library to check postconditions @c f() or @c f(result). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::postcondition_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). This functor must be a nullary functor @c f() if @c VirtualResult is @c void, otherwise it must be a unary functor @c f(result) accepting the return value @c result as a parameter of type <c>VirtualResult const&</c> (to avoid extra copies of the return value, or of type @c VirtualResult or <c>VirtualResult const</c> if extra copies of the return value are irrelevant). @return After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. */ template<typename F> specify_except postcondition( F const& #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ } /** Allow to specify exception guarantees. @param f Nullary functor called by this library to check exception guarantees @c f(). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::except_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). @return After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. */ template<typename F> specify_nothing except( F const& #if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ } /** @cond */ private: BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( specify_old_postcondition_except, boost::contract::detail::cond_post<typename boost::contract::detail::none_if_void<VirtualResult>::type> ) // Friends (used to limit library's public API). friend class check; friend class specify_precondition_old_postcondition_except<VirtualResult>; template<class C> friend specify_old_postcondition_except<> constructor(C*); template<class C> friend specify_old_postcondition_except<> destructor(C*); /** @endcond */ }; /** Allow to specify preconditions, old values copied at body, postconditions, and exception guarantees. Allow to specify functors this library will call to check preconditions, copy old values at body, check postconditions, and check exception guarantees. This object is internally constructed by the library when users specify contracts calling @RefFunc{boost::contract::function} and similar functions (that is why this class does not have a public constructor). @see @RefSect{tutorial.preconditions, Preconditions}, @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}, @RefSect{tutorial.postconditions, Postconditions}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} @tparam VirtualResult Return type of the enclosing function declaring the contract if that is either a virtual or an overriding public function, otherwise this is always @c void. (Usually this template parameter is automatically deduced by C++ and it does not need to be explicitly specified by programmers.) */ template< typename VirtualResult /* = void (already in fwd decl from decl.hpp) */ #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN = void #endif > class specify_precondition_old_postcondition_except { // Priv. copyable (as *). public: /** Destruct this object. @b Throws: This is declared @c noexcept(false) since C++11 to allow users to program failure handlers that throw exceptions on contract assertion failures (not the default, see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}). */ ~specify_precondition_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {} /** Allow to specify preconditions. @param f Nullary functor called by this library to check preconditions @c f(). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::precondition_failure}). This functor should capture variables by (constant) value, or better by (constant) reference (to avoid extra copies). @return After preconditions have been specified, the object returned by this function allows to optionally specify old values copied at body, postconditions, and exception guarantees. */ template<typename F> specify_old_postcondition_except<VirtualResult> precondition( F const& #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ } /** Allow to specify old values copied at body. It should often be sufficient to initialize old value pointers as soon as they are declared, without using this function (see @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body}). @param f Nullary functor called by this library @c f() to assign old value copies just before the body is executed but after entry invariants (when they apply) and preconditions are checked. Old value pointers within this functor call are usually assigned using @RefMacro{BOOST_CONTRACT_OLDOF}. Any exception thrown by a call to this functor will result in this library calling @RefFunc{boost::contract::old_failure} (because old values could not be copied to check postconditions and exception guarantees). This functor should capture old value pointers by references so they can be assigned (all other variables needed to evaluate old value expressions can be captured by (constant) value, or better by (constant) reference to avoid extra copies). @return After old values copied at body have been specified, the object returned by this functions allows to optionally specify postconditions and exception guarantees. */ template<typename F> specify_postcondition_except<VirtualResult> old( F const& #if !defined(BOOST_CONTRACT_NO_OLDS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_OLD_IMPL_ } /** Allow to specify postconditions. @param f Functor called by this library to check postconditions @c f() or @c f(result). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::postcondition_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). This functor must be a nullary functor @c f() if @c VirtualResult is @c void, otherwise it must be a unary functor @c f(result) accepting the return value @c result as a parameter of type <c>VirtualResult const&</c> (to avoid extra copies of the return value, or of type @c VirtualResult or <c>VirtualResult const</c> if extra copies of the return value are irrelevant). @return After postconditions have been specified, the object returned by this function allows to optionally specify exception guarantees. */ template<typename F> specify_except postcondition( F const& #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ } /** Allow to specify exception guarantees. @param f Nullary functor called by this library to check exception guarantees @c f(). Assertions within this functor are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract assertion failure (and will result in this library calling @RefFunc{boost::contract::except_failure}). This functor should capture variables by (constant) references (to access the values they will have at function exit). @return After exception guarantees have been specified, the object returned by this function does not allow to specify any additional contract. */ template<typename F> specify_nothing except( F const& #if !defined(BOOST_CONTRACT_NO_EXCEPTS) || \ defined(BOOST_CONTRACT_DETAIL_DOXYGEN) f #endif // Else, no name (avoid unused param warning). ) { BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ } /** @cond */ private: BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( specify_precondition_old_postcondition_except, boost::contract::detail::cond_post<typename boost::contract::detail::none_if_void<VirtualResult>::type> ) // Friends (used to limit library's public API). friend class check; friend specify_precondition_old_postcondition_except<> function(); template<class C> friend specify_precondition_old_postcondition_except<> public_function(); template<class C> friend specify_precondition_old_postcondition_except<> public_function(C*); template<class C> friend specify_precondition_old_postcondition_except<> public_function( virtual_*, C*); template<typename VR, class C> friend specify_precondition_old_postcondition_except<VR> public_function( virtual_*, VR&, C*); BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(1, O, VR, F, C, Args, v, r, f, obj, args) /** @endcond */ }; } } // namespace #endif // #include guard exception.hpp 0000644 00000102737 15125714652 0007275 0 ustar 00 #ifndef BOOST_CONTRACT_EXCEPTION_HPP_ #define BOOST_CONTRACT_EXCEPTION_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Handle contract assertion failures. */ // IMPORTANT: Included by contract_macro.hpp so trivial headers only. #include <boost/contract/core/config.hpp> #include <boost/contract/detail/declspec.hpp> // No compile-time overhead. #include <boost/function.hpp> #include <boost/config.hpp> #include <exception> #include <string> // NOTE: This code should not change (not even its impl) based on the // CONTRACT_NO_... macros. For example, preconditions_failure() should still // all the set precondition failure handler even when NO_PRECONDITIONS is // #defined, because user code might explicitly call precondition_failure() // (for whatever reason...). Otherwise, the public API of this lib will change. #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN // Needed for `std::` prefix to show (but removed via `EXCLUDE_SYMBOLS=std`). namespace std { class exception {}; class bad_cast {}; } #endif namespace boost { namespace contract { /** Public base class for all exceptions directly thrown by this library. This class does not inherit from @c std::exception because exceptions deriving from this class will do that (inheriting from @c std::exception, @c std::bad_cast, etc.). @see @RefClass{boost::contract::assertion_failure}, @RefClass{boost::contract::bad_virtual_result_cast}, etc. */ class BOOST_CONTRACT_DETAIL_DECLSPEC exception { public: /** Destruct this object. @b Throws: This is declared @c noexcept (or @c throw() before C++11). */ virtual ~exception() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; }; #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable: 4275) // Bases w/o DLL spec (bad_cast, etc). #pragma warning(disable: 4251) // Members w/o DLL spec (string for what_). #endif /** Exception thrown when inconsistent return values are passed to overridden virtual public functions. This exception is thrown when programmers pass to this library return value parameters for public function overrides in derived classes that are not consistent with the return type parameter passed for the virtual public function being overridden from the base classes. This allows this library to give more descriptive error messages in such cases of misuse. This exception is internally thrown by this library and programmers should not need to throw it from user code. @see @RefSect{tutorial.public_function_overrides__subcontracting_, Public Function Overrides} */ class BOOST_CONTRACT_DETAIL_DECLSPEC bad_virtual_result_cast : // Copy (as str). public std::bad_cast, public boost::contract::exception { public: /** Construct this object with the name of the from- and to- result types. @param from_type_name Name of the from-type (source of the cast). @param to_type_name Name of the to-type (destination of the cast). */ explicit bad_virtual_result_cast(char const* from_type_name, char const* to_type_name); /** Destruct this object. @b Throws: This is declared @c noexcept (or @c throw() before C++11). */ virtual ~bad_virtual_result_cast() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; /** Description for this error (containing both from- and to- type names). @b Throws: This is declared @c noexcept (or @c throw() before C++11). */ virtual char const* what() const /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; /** @cond */ private: std::string what_; /** @endcond */ }; /** Exception typically used to report a contract assertion failure. This exception is thrown by code expanded by @RefMacro{BOOST_CONTRACT_ASSERT} (but it can also be thrown by user code programmed manually without that macro). This exception is typically used to report contract assertion failures because it contains detailed information about the file name, line number, and source code of the asserted condition (so it can be used by this library to provide detailed error messages when handling contract assertion failures). However, any other exception can be used to report a contract assertion failure (including user-defined exceptions). This library will call the appropriate contract failure handler function (@RefFunc{boost::contract::precondition_failure}, etc.) when this or any other exception is thrown while checking contracts (by default, these failure handler functions print an error message to @c std::cerr and terminate the program, but they can be customized to take any other action). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} */ class BOOST_CONTRACT_DETAIL_DECLSPEC assertion_failure : // Copy (as str, etc.). public std::exception, public boost::contract::exception { public: /** Construct this object with file name, line number, and source code text of an assertion condition (all optional). This constructor can also be used to specify no information (default constructor), or to specify only file name and line number but not source code text (because of the parameter default values). @param file Name of the file containing the assertion (usually set using <c>__FILE__</c>). @param line Number of the line containing the assertion (usually set using <c>__LINE__</c>). @param code Text listing the source code of the assertion condition. */ explicit assertion_failure(char const* file = "", unsigned long line = 0, char const* code = ""); /** Construct this object only with the source code text of the assertion condition. @param code Text listing the source code of the assertion condition. */ explicit assertion_failure(char const* code); /** Destruct this object. @b Throws: This is declared @c noexcept (or @c throw() before C++11). */ virtual ~assertion_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; /** String describing the failed assertion. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A string formatted similarly to the following: <c>assertion "`code()`" failed: file "`file()`", line \`line()\`</c> (where `` indicate execution quotes). File, line, and code will be omitted from this string if they were not specified when constructing this object. */ virtual char const* what() const /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; /** Name of the file containing the assertion. @return File name as specified at construction (or @c "" if no file was specified). */ char const* file() const; /** Number of the line containing the assertion. @return Line number as specified at construction (or @c 0 if no line number was specified). */ unsigned long line() const; /** Text listing the source code of the assertion condition. @return Assertion condition source code as specified at construction (or @c "" if no source code text was specified). */ char const* code() const; /** @cond */ private: void init(); char const* file_; unsigned long line_; char const* code_; std::string what_; /** @endcond */ }; #ifdef BOOST_MSVC #pragma warning(pop) #endif /** Indicate the kind of operation where the contract assertion failed. This is passed as a parameter to the assertion failure handler functions. For example, it might be necessary to know in which operation an assertion failed to make sure exceptions are never thrown from destructors, not even when contract failure handlers are programmed by users to throw exceptions instead of terminating the program. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} */ enum from { /** Assertion failed when checking contracts for constructors. */ from_constructor, /** Assertion failed when checking contracts for destructors . */ from_destructor, /** Assertion failed when checking contracts for functions (members or not, public or not). */ from_function }; /** Type of assertion failure handler functions (with @c from parameter). Assertion failure handler functions specified by this type must be functors returning @c void and taking a single parameter of type @RefEnum{boost::contract::from}. For example, this is used to specify contract failure handlers for class invariants, preconditions, postconditions, and exception guarantees. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} */ typedef boost::function<void (from)> from_failure_handler; /** Type of assertion failure handler functions (without @c from parameter). Assertion failure handler functions specified by this type must be nullary functors returning @c void. For example, this is used to specify contract failure handlers for implementation checks. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} */ typedef boost::function<void ()> failure_handler; /** @cond */ namespace exception_ { // Check failure. BOOST_CONTRACT_DETAIL_DECLSPEC failure_handler const& set_check_failure_unlocked(failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC failure_handler const& set_check_failure_locked(failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC failure_handler get_check_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC failure_handler get_check_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void check_failure_unlocked() /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void check_failure_locked() /* can throw */; // Precondition failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_pre_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_pre_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_pre_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_pre_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void pre_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void pre_failure_locked(from where) /* can throw */; // Postcondition failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_post_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_post_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_post_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_post_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void post_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void post_failure_locked(from where) /* can throw */; // Except failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_except_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_except_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_except_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_except_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void except_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void except_failure_locked(from where) /* can throw */; // Old-copy failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_old_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_old_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_old_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_old_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void old_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void old_failure_locked(from where) /* can throw */; // Entry invariant failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_entry_inv_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_entry_inv_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_entry_inv_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_entry_inv_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void entry_inv_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void entry_inv_failure_locked(from where) /* can throw */; // Exit invariant failure. BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const& set_exit_inv_failure_unlocked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler const&set_exit_inv_failure_locked( from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_exit_inv_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC from_failure_handler get_exit_inv_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; BOOST_CONTRACT_DETAIL_DECLSPEC void exit_inv_failure_unlocked(from where) /* can throw */; BOOST_CONTRACT_DETAIL_DECLSPEC void exit_inv_failure_locked(from where) /* can throw */; } /** @endcond */ } } // namespace /** @cond */ #ifdef BOOST_CONTRACT_HEADER_ONLY // NOTE: This header must be included in the middle of this file (because // its impl depends on both from and assert_failure types). This is not // ideal, but it is better than splitting this file into multiple // independent ones because all content in this file is logically related // from the user prospective. #include <boost/contract/detail/inlined/core/exception.hpp> #endif /** @endcond */ namespace boost { namespace contract { // Following must be inline for static linkage (no DYN_LINK and no HEADER_ONLY). /** Set failure handler for implementation checks. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.implementation_checks, Implementation Checks} */ inline failure_handler const& set_check_failure(failure_handler const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_check_failure_locked(f); #else return exception_::set_check_failure_unlocked(f); #endif } /** Return failure handler currently set for implementation checks. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.implementation_checks, Implementation Checks} */ inline failure_handler get_check_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_check_failure_locked(); #else return exception_::get_check_failure_unlocked(); #endif } /** Call failure handler for implementation checks. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on implementation check failures (not the default). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.implementation_checks, Implementation Checks} */ inline void check_failure() /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::check_failure_locked(); #else exception_::check_failure_unlocked(); #endif } /** Set failure handler for preconditions. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.preconditions, Preconditions} */ inline from_failure_handler const& set_precondition_failure(from_failure_handler const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_pre_failure_locked(f); #else return exception_::set_pre_failure_unlocked(f); #endif } /** Return failure handler currently set for preconditions. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.preconditions, Preconditions} */ inline from_failure_handler get_precondition_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_pre_failure_locked(); #else return exception_::get_pre_failure_unlocked(); #endif } /** Call failure handler for preconditions. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default). @param where Operation that failed the contract assertion (when this function is called by this library, this parameter will never be @c from_destructor because destructors do not have preconditions). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.preconditions, Preconditions} */ inline void precondition_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::pre_failure_locked(where); #else exception_::pre_failure_unlocked(where); #endif } /** Set failure handler for postconditions. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.postconditions, Postconditions} */ inline from_failure_handler const& set_postcondition_failure( from_failure_handler const& f ) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_post_failure_locked(f); #else return exception_::set_post_failure_unlocked(f); #endif } /** Return failure handler currently set for postconditions. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.postconditions, Postconditions} */ inline from_failure_handler get_postcondition_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_post_failure_locked(); #else return exception_::get_post_failure_unlocked(); #endif } /** Call failure handler for postconditions. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default). @param where Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.postconditions, Postconditions} */ inline void postcondition_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::post_failure_locked(where); #else exception_::post_failure_unlocked(where); #endif } /** Set failure handler for exception guarantees. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} */ inline from_failure_handler const& set_except_failure(from_failure_handler const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_except_failure_locked(f); #else return exception_::set_except_failure_unlocked(f); #endif } /** Return failure handler currently set for exception guarantees. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} */ inline from_failure_handler get_except_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_except_failure_locked(); #else return exception_::get_except_failure_unlocked(); #endif } /** Call failure handler for exception guarantees. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default), however: @warning When this failure handler is called there is already an active exception (the one that caused the exception guarantees to be checked in the first place). Therefore, programming this failure handler to throw yet another exception will force C++ to automatically terminate the program. @param where Operation that failed the contract assertion. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.exception_guarantees, Exception Guarantees} */ inline void except_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::except_failure_locked(where); #else exception_::except_failure_unlocked(where); #endif } /** Set failure handler for old values copied at body. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body} */ inline from_failure_handler const& set_old_failure(from_failure_handler const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_old_failure_locked(f); #else return exception_::set_old_failure_unlocked(f); #endif } /** Return failure handler currently set for old values copied at body. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body} */ inline from_failure_handler get_old_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_old_failure_locked(); #else return exception_::get_old_failure_unlocked(); #endif } /** Call failure handler for old values copied at body. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default). @param where Operation that failed the old value copy (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{advanced.old_values_copied_at_body, Old Values Copied at Body} */ inline void old_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::old_failure_locked(where); #else exception_::old_failure_unlocked(where); #endif } /** Set failure handler for class invariants at entry. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline from_failure_handler const& set_entry_invariant_failure( from_failure_handler const& f )/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_entry_inv_failure_locked(f); #else return exception_::set_entry_inv_failure_unlocked(f); #endif } /** Return failure handler currently set for class invariants at entry. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline from_failure_handler get_entry_invariant_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_entry_inv_failure_locked(); #else return exception_::get_entry_inv_failure_unlocked(); #endif } /** Call failure handler for class invariants at entry. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default). @param where Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline void entry_invariant_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::entry_inv_failure_locked(where); #else return exception_::entry_inv_failure_unlocked(where); #endif } /** Set failure handler for class invariants at exit. Set a new failure handler and returns it. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline from_failure_handler const& set_exit_invariant_failure( from_failure_handler const& f ) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::set_exit_inv_failure_locked(f); #else return exception_::set_exit_inv_failure_unlocked(f); #endif } /** Return failure handler currently set for class invariants at exit. This is often called only internally by this library. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @return A copy of the failure handler currently set. @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline from_failure_handler get_exit_invariant_failure() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS return exception_::get_exit_inv_failure_locked(); #else return exception_::get_exit_inv_failure_unlocked(); #endif } /** Call failure handler for class invariants at exit. This is often called only internally by this library. @b Throws: This can throw in case programmers specify a failure handler that throws exceptions on contract assertion failures (not the default). @param where Operation that failed the contract assertion (e.g., this might be useful to program failure handler functors that never throw from destructors, not even when they are programmed by users to throw exceptions instead of terminating the program). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ inline void exit_invariant_failure(from where) /* can throw */ { #ifndef BOOST_CONTRACT_DISABLE_THREADS exception_::exit_inv_failure_locked(where); #else exception_::exit_inv_failure_unlocked(where); #endif } /** Set failure handler for class invariants (at both entry and exit). This is provided for convenience and it is equivalent to call both @RefFunc{boost::contract::set_entry_invariant_failure} and @RefFunc{boost::contract::set_exit_invariant_failure} with the same functor parameter @p f. @b Throws: This is declared @c noexcept (or @c throw() before C++11). @param f New failure handler functor to set for both entry and exit invariants. @return Same failure handler functor @p f passed as parameter (e.g., for concatenating function calls). @see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, @RefSect{tutorial.class_invariants, Class Invariants}, @RefSect{extras.volatile_public_functions, Volatile Public Functions} */ /** @cond */ BOOST_CONTRACT_DETAIL_DECLSPEC /** @endcond */ from_failure_handler const& set_invariant_failure(from_failure_handler const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; } } // namespace #endif // #include guard constructor_precondition.hpp 0000644 00000010600 15125714652 0012424 0 ustar 00 #ifndef BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION_HPP_ #define BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Program preconditions for constructors. */ // IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. #include <boost/contract/core/config.hpp> #ifndef BOOST_CONTRACT_NO_PRECONDITIONS #include <boost/contract/core/exception.hpp> #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION #include <boost/contract/detail/checking.hpp> #endif #endif namespace boost { namespace contract { /** Program preconditions for constructors. This class must be the very first base of the class declaring the constructor for which preconditions are programmed (that way constructor arguments can be checked by preconditions even before they are used to initialize other base classes): @code class u #define BASES private boost::contract::constructor_precondition<u>, \ public b : BASES { friend class boost::contract::access; typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; #undef BASES public: explicit u(unsigned x) : boost::contract::constructor_precondition<u>([&] { BOOST_CONTRACT_ASSERT(x != 0); ... }), b(1.0 / float(x)) { ... } ... }; @endcode User-defined classes should inherit privately from this class (to not alter the public interface of user-defined classes). In addition, this class should never be declared as a virtual base (because virtual bases are initialized only once across the entire inheritance hierarchy preventing preconditions of other base classes from being checked). This class cannot be used this way in a @c union because unions cannot have base classes in C++. Instead, this class is used in a @c union to declare a local object within the constructor definition just before @RefFunc{boost::contract::constructor} is used (see @RefSect{extras.unions, Unions}). @see @RefSect{tutorial.constructors, Constructors} @tparam Class The class type of the constructor for which preconditions are being programmed. */ template<class Class> class constructor_precondition { // Copyable (has no data). public: /** Construct this object without specifying constructor preconditions. This is implicitly called for those constructors of the contracted class that do not specify preconditions. @note The implementation of this library is optimized so that calling this default constructor should amount to negligible compile-time and run-time overheads (likely to be optimized away completely by most compilers). */ constructor_precondition() {} /** Construct this object specifying constructor preconditions. @param f Nullary functor called by this library to check constructor preconditions @c f(). Assertions within this functor call are usually programmed using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call to this functor indicates a contract failure (and will result in this library calling @RefFunc{boost::contract::precondition_failure}). This functor should capture variables by (constant) value, or better by (constant) reference to avoid extra copies. */ template<typename F> explicit constructor_precondition(F const& f) { #ifndef BOOST_CONTRACT_NO_PRECONDITIONS try { #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION if(boost::contract::detail::checking::already()) return; #ifndef BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION boost::contract::detail::checking k; #endif #endif f(); } catch(...) { precondition_failure(from_constructor); } #endif } // Default copy operations (so user's derived classes can be copied, etc.). }; } } // namespace #endif // #include guard access.hpp 0000644 00000014704 15125714652 0006534 0 ustar 00 #ifndef BOOST_CONTRACT_ACCESS_HPP_ #define BOOST_CONTRACT_ACCESS_HPP_ // Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html /** @file Allow to declare invariants, base types, etc all as private members. */ // IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. #include <boost/contract/core/config.hpp> #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) #include <boost/contract/detail/decl.hpp> #include <boost/contract/detail/type_traits/mirror.hpp> #endif #ifndef BOOST_CONTRACT_NO_INVARIANTS #include <boost/contract/detail/debug.hpp> #include <boost/function_types/property_tags.hpp> #include <boost/mpl/vector.hpp> #endif namespace boost { namespace contract { #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) class virtual_; namespace detail { BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, /* is_friend = */ 0, OO, RR, FF, CC, AArgs); } #endif #ifndef BOOST_CONTRACT_NO_INVARIANTS namespace detail { template<typename RR, class CC> class cond_inv; } #endif /** Declare this class as friend to program invariants and base types as private members. Declare this class a friend of the user-defined class specifying the contracts and then invariant functions and the base types @c typedef can be declared as non-public members: @code class u #define BASES public b, private w : BASES { friend class boost::contract::access; typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; // Private. #undef BASES void invariant() const { ... } // Private (same for static and volatile). public: ... }; @endcode In real code, programmers will likely chose to declare this class as friend so to fully control public interfaces of their user-defined classes (this is not extensively done in the examples of this documentation only for brevity). This class is not intended to be directly used by programmers a part from being declared as @c friend (and that is why this class does not have any public member and it is not copyable). @warning Not declaring this class friend of user-defined classes will cause compiler errors on some compilers (e.g., MSVC) because the private members needed to check the contracts will not be accessible. On other compilers (e.g., GCC and CLang), the private access will instead fail SFINAE and no compiler error will be reported while invariants and subcontracting will be silently skipped at run-time. Therefore, programmers must make sure to either declare this class as friend or to always declare invariant functions and base types @c typedef as public members. @see @RefSect{advanced.access_specifiers, Access Specifiers} */ class access { // Non-copyable (see below). /** @cond */ private: // No public APIs (so users cannot use it directly by mistake). access(); // Should never be constructed (not even internally). ~access(); // No boost::noncopyable to avoid its overhead when contracts disabled. access(access&); access& operator=(access&); #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) BOOST_CONTRACT_DETAIL_MIRROR_HAS_TYPE(has_base_types, BOOST_CONTRACT_BASES_TYPEDEF) template<class C> struct base_types_of { typedef typename C::BOOST_CONTRACT_BASES_TYPEDEF type; }; #endif #ifndef BOOST_CONTRACT_NO_INVARIANTS BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( has_static_invariant_f, BOOST_CONTRACT_STATIC_INVARIANT_FUNC) BOOST_CONTRACT_DETAIL_MIRROR_HAS_STATIC_MEMBER_FUNCTION( has_static_invariant_s, BOOST_CONTRACT_STATIC_INVARIANT_FUNC) template<class C> struct has_static_invariant : has_static_invariant_s<C, void, boost::mpl::vector<> > {}; template<class C> static void static_invariant() { C::BOOST_CONTRACT_STATIC_INVARIANT_FUNC(); } template<class C> class static_invariant_addr { // Class so to pass it as tparam. typedef void (*func_ptr)(); public: static func_ptr apply() { return &C::BOOST_CONTRACT_STATIC_INVARIANT_FUNC; } }; BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( has_invariant_f, BOOST_CONTRACT_INVARIANT_FUNC) BOOST_CONTRACT_DETAIL_MIRROR_HAS_STATIC_MEMBER_FUNCTION( has_invariant_s, BOOST_CONTRACT_INVARIANT_FUNC) template<class C> struct has_cv_invariant : has_invariant_f<C, void, boost::mpl::vector<>, boost::function_types::cv_qualified> {}; template<class C> struct has_const_invariant : has_invariant_f<C, void, boost::mpl:: vector<>, boost::function_types::const_qualified> {}; template<class C> static void cv_invariant(C const volatile* obj) { BOOST_CONTRACT_DETAIL_DEBUG(obj); obj->BOOST_CONTRACT_INVARIANT_FUNC(); } template<class C> static void const_invariant(C const* obj) { BOOST_CONTRACT_DETAIL_DEBUG(obj); obj->BOOST_CONTRACT_INVARIANT_FUNC(); } #endif // Friends (used to limit library's public API). // NOTE: Using friends here and in all other places in this library // does not increase compilation times (I experimented replacing all // friends with public and got the same compilation times). #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ defined(BOOST_CONTRACT_STATIC_LINK) BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, /* is_friend = */ 1, OO, RR, FF, CC, AArgs); BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(1, OO, RR, FF, CC, AArgs, vv, rr, ff, oobj, aargs) #endif #ifndef BOOST_CONTRACT_NO_INVARIANTS template<typename RR, class CC> friend class boost::contract::detail::cond_inv; #endif /** @endcond */ }; } } // namespace #endif // #include guard core.hpp 0000644 00000033724 15125716360 0006224 0 ustar 00 /* * Copyright Andrey Semashev 2007 - 2015. * 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) */ /*! * \file core/core.hpp * \author Andrey Semashev * \date 19.04.2007 * * This header contains logging core class definition. */ #ifndef BOOST_LOG_CORE_CORE_HPP_INCLUDED_ #define BOOST_LOG_CORE_CORE_HPP_INCLUDED_ #include <utility> #include <boost/smart_ptr/shared_ptr.hpp> #include <boost/move/core.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/detail/light_function.hpp> #include <boost/log/core/record.hpp> #include <boost/log/attributes/attribute_set.hpp> #include <boost/log/attributes/attribute_name.hpp> #include <boost/log/attributes/attribute.hpp> #include <boost/log/attributes/attribute_value_set.hpp> #include <boost/log/expressions/filter.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { BOOST_LOG_OPEN_NAMESPACE #ifndef BOOST_LOG_DOXYGEN_PASS namespace sinks { class sink; } // namespace sinks #endif // BOOST_LOG_DOXYGEN_PASS class core; typedef shared_ptr< core > core_ptr; /*! * \brief Logging library core class * * The logging core is used to interconnect log sources and sinks. It also provides * a number of basic features, like global filtering and global and thread-specific attribute storage. * * The logging core is a singleton. Users can acquire the core instance by calling the static method <tt>get</tt>. */ class core { public: //! Exception handler function type typedef boost::log::aux::light_function< void () > exception_handler_type; private: //! Implementation type struct implementation; friend struct implementation; private: //! A pointer to the implementation implementation* m_impl; private: //! \cond core(); //! \endcond public: /*! * Destructor. Destroys the core, releases any sinks and attributes that were registered. */ ~core(); /*! * \return The method returns a pointer to the logging core singleton instance. */ BOOST_LOG_API static core_ptr get(); /*! * The method enables or disables logging. * * Setting this status to \c false allows you to completely wipe out any logging activity, including * filtering and generation of attribute values. It is useful if you want to completely disable logging * in a running application. The state of logging does not alter any other properties of the logging * library, such as filters or sinks, so you can enable logging with the very same settings that you had * when the logging was disabled. * This feature may also be useful if you want to perform major changes to logging configuration and * don't want your application to block on opening or pushing a log record. * * By default logging is enabled. * * \param enabled The actual flag of logging activity. * \return The previous value of enabled/disabled logging flag */ BOOST_LOG_API bool set_logging_enabled(bool enabled = true); /*! * The method allows to detect if logging is enabled. See the comment for \c set_logging_enabled. */ BOOST_LOG_API bool get_logging_enabled() const; /*! * The method sets the global logging filter. The filter is applied to every log record that is processed. * * \param filter The filter function object to be installed. */ BOOST_LOG_API void set_filter(filter const& filter); /*! * The method removes the global logging filter. All log records are passed to sinks without global filtering applied. */ BOOST_LOG_API void reset_filter(); /*! * The method adds a new sink. The sink is included into logging process immediately after being added and until being removed. * No sink can be added more than once at the same time. If the sink is already registered, the call is ignored. * * \param s The sink to be registered. */ BOOST_LOG_API void add_sink(shared_ptr< sinks::sink > const& s); /*! * The method removes the sink from the output. The sink will not receive any log records after removal. * The call has no effect if the sink is not registered. * * \param s The sink to be unregistered. */ BOOST_LOG_API void remove_sink(shared_ptr< sinks::sink > const& s); /*! * The method removes all registered sinks from the output. The sinks will not receive any log records after removal. */ BOOST_LOG_API void remove_all_sinks(); /*! * The method performs flush on all registered sinks. * * \note This method may take long time to complete as it may block until all sinks manage to process all buffered log records. * The call will also block all logging attempts until the operation completes. */ BOOST_LOG_API void flush(); /*! * The method adds an attribute to the global attribute set. The attribute will be implicitly added to every log record. * * \param name The attribute name. * \param attr The attribute factory. * \return A pair of values. If the second member is \c true, then the attribute is added and the first member points to the * attribute. Otherwise the attribute was not added and the first member points to the attribute that prevents * addition. */ BOOST_LOG_API std::pair< attribute_set::iterator, bool > add_global_attribute(attribute_name const& name, attribute const& attr); /*! * The method removes an attribute from the global attribute set. * * \pre The attribute was added with the \c add_global_attribute call. * \post The attribute is no longer registered as a global attribute. The iterator is invalidated after removal. * * \param it Iterator to the previously added attribute. */ BOOST_LOG_API void remove_global_attribute(attribute_set::iterator it); /*! * The method returns a copy of the complete set of currently registered global attributes. */ BOOST_LOG_API attribute_set get_global_attributes() const; /*! * The method replaces the complete set of currently registered global attributes with the provided set. * * \note The method invalidates all iterators and references that may have been returned * from the \c add_global_attribute method. * * \param attrs The set of attributes to be installed. */ BOOST_LOG_API void set_global_attributes(attribute_set const& attrs); /*! * The method adds an attribute to the thread-specific attribute set. The attribute will be implicitly added to * every log record made in the current thread. * * \note In single-threaded build the effect is the same as adding the attribute globally. This, however, does * not imply that iterators to thread-specific and global attributes are interchangeable. * * \param name The attribute name. * \param attr The attribute factory. * \return A pair of values. If the second member is \c true, then the attribute is added and the first member points to the * attribute. Otherwise the attribute was not added and the first member points to the attribute that prevents * addition. */ BOOST_LOG_API std::pair< attribute_set::iterator, bool > add_thread_attribute(attribute_name const& name, attribute const& attr); /*! * The method removes an attribute from the thread-specific attribute set. * * \pre The attribute was added with the \c add_thread_attribute call. * \post The attribute is no longer registered as a thread-specific attribute. The iterator is invalidated after removal. * * \param it Iterator to the previously added attribute. */ BOOST_LOG_API void remove_thread_attribute(attribute_set::iterator it); /*! * The method returns a copy of the complete set of currently registered thread-specific attributes. */ BOOST_LOG_API attribute_set get_thread_attributes() const; /*! * The method replaces the complete set of currently registered thread-specific attributes with the provided set. * * \note The method invalidates all iterators and references that may have been returned * from the \c add_thread_attribute method. * * \param attrs The set of attributes to be installed. */ BOOST_LOG_API void set_thread_attributes(attribute_set const& attrs); /*! * The method sets exception handler function. The function will be called with no arguments * in case if an exception occurs during either \c open_record or \c push_record method * execution. Since exception handler is called from a \c catch statement, the exception * can be rethrown in order to determine its type. * * By default no handler is installed, thus any exception is propagated as usual. * * \sa See also: <tt>utility/exception_handler.hpp</tt> * \param handler Exception handling function * * \note The exception handler can be invoked in several threads concurrently. * Thread interruptions are not affected by exception handlers. */ BOOST_LOG_API void set_exception_handler(exception_handler_type const& handler); /*! * The method attempts to open a new record to be written. While attempting to open a log record all filtering is applied. * A successfully opened record can be pushed further to sinks by calling the \c push_record method or simply destroyed by * destroying the returned object. * * More than one open records are allowed, such records exist independently. All attribute values are acquired during opening * the record and do not interact between records. * * The returned records can be copied, however, they must not be passed between different threads. * * \param source_attributes The set of source-specific attributes to be attached to the record to be opened. * \return A valid log record if the record is opened, an invalid record object if not (e.g. because it didn't pass filtering). * * \b Throws: If an exception handler is installed, only throws if the handler throws. Otherwise may * throw if one of the sinks throws, or some system resource limitation is reached. */ BOOST_LOG_API record open_record(attribute_set const& source_attributes); /*! * The method attempts to open a new record to be written. While attempting to open a log record all filtering is applied. * A successfully opened record can be pushed further to sinks by calling the \c push_record method or simply destroyed by * destroying the returned object. * * More than one open records are allowed, such records exist independently. All attribute values are acquired during opening * the record and do not interact between records. * * The returned records can be copied, however, they must not be passed between different threads. * * \param source_attributes The set of source-specific attribute values to be attached to the record to be opened. * \return A valid log record if the record is opened, an invalid record object if not (e.g. because it didn't pass filtering). * * \b Throws: If an exception handler is installed, only throws if the handler throws. Otherwise may * throw if one of the sinks throws, or some system resource limitation is reached. */ BOOST_LOG_API record open_record(attribute_value_set const& source_attributes); /*! * The method attempts to open a new record to be written. While attempting to open a log record all filtering is applied. * A successfully opened record can be pushed further to sinks by calling the \c push_record method or simply destroyed by * destroying the returned object. * * More than one open records are allowed, such records exist independently. All attribute values are acquired during opening * the record and do not interact between records. * * The returned records can be copied, however, they must not be passed between different threads. * * \param source_attributes The set of source-specific attribute values to be attached to the record to be opened. The contents * of this container are unspecified after this call. * \return A valid log record if the record is opened, an invalid record object if not (e.g. because it didn't pass filtering). * * \b Throws: If an exception handler is installed, only throws if the handler throws. Otherwise may * throw if one of the sinks throws, or some system resource limitation is reached. */ BOOST_FORCEINLINE record open_record(BOOST_RV_REF(attribute_value_set) source_attributes) { return open_record_move(static_cast< attribute_value_set& >(source_attributes)); } /*! * The method pushes the record to sinks. The record is moved from in the process. * * \pre <tt>!!rec == true</tt> * \post <tt>!rec == true</tt> * \param rec A previously successfully opened log record. * * \b Throws: If an exception handler is installed, only throws if the handler throws. Otherwise may * throw if one of the sinks throws. */ BOOST_FORCEINLINE void push_record(BOOST_RV_REF(record) rec) { push_record_move(static_cast< record& >(rec)); } BOOST_DELETED_FUNCTION(core(core const&)) BOOST_DELETED_FUNCTION(core& operator= (core const&)) #ifndef BOOST_LOG_DOXYGEN_PASS private: //! Opens log record. This function is mostly needed to maintain ABI stable between C++03 and C++11. BOOST_LOG_API record open_record_move(attribute_value_set& source_attributes); //! The method pushes the record to sinks. BOOST_LOG_API void push_record_move(record& rec); #endif // BOOST_LOG_DOXYGEN_PASS }; BOOST_LOG_CLOSE_NAMESPACE // namespace log } // namespace boost #include <boost/log/detail/footer.hpp> #endif // BOOST_LOG_CORE_CORE_HPP_INCLUDED_ record_view.hpp 0000644 00000016463 15125716360 0007605 0 ustar 00 /* * Copyright Andrey Semashev 2007 - 2015. * 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) */ /*! * \file record_view.hpp * \author Andrey Semashev * \date 09.03.2009 * * This header contains a logging record view class definition. */ #ifndef BOOST_LOG_CORE_RECORD_VIEW_HPP_INCLUDED_ #define BOOST_LOG_CORE_RECORD_VIEW_HPP_INCLUDED_ #include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/move/core.hpp> #include <boost/move/utility_core.hpp> #include <boost/core/explicit_operator_bool.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/attributes/attribute_value_set.hpp> #include <boost/log/expressions/keyword_fwd.hpp> #ifndef BOOST_LOG_NO_THREADS #include <boost/detail/atomic_count.hpp> #endif // BOOST_LOG_NO_THREADS #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { BOOST_LOG_OPEN_NAMESPACE #ifndef BOOST_LOG_DOXYGEN_PASS class core; class record; #endif // BOOST_LOG_DOXYGEN_PASS /*! * \brief Logging record view class * * The logging record encapsulates all information related to a single logging statement, * in particular, attribute values view and the log message string. The view is immutable, * it is implemented as a wrapper around a reference-counted implementation. */ class record_view { BOOST_COPYABLE_AND_MOVABLE(record_view) friend class core; friend class record; #ifndef BOOST_LOG_DOXYGEN_PASS private: //! Private data struct private_data; friend struct private_data; //! Publicly available record data struct public_data { //! Reference counter #ifndef BOOST_LOG_NO_THREADS mutable boost::detail::atomic_count m_ref_counter; #else mutable unsigned int m_ref_counter; #endif // BOOST_LOG_NO_THREADS //! Attribute values view attribute_value_set m_attribute_values; //! Constructor from the attribute value set explicit public_data(BOOST_RV_REF(attribute_value_set) values) BOOST_NOEXCEPT : m_ref_counter(1), m_attribute_values(boost::move(values)) { } //! Destructor BOOST_LOG_API static void destroy(const public_data* p) BOOST_NOEXCEPT; protected: ~public_data() {} BOOST_DELETED_FUNCTION(public_data(public_data const&)) BOOST_DELETED_FUNCTION(public_data& operator= (public_data const&)) friend void intrusive_ptr_add_ref(const public_data* p) BOOST_NOEXCEPT { ++p->m_ref_counter; } friend void intrusive_ptr_release(const public_data* p) BOOST_NOEXCEPT { if (--p->m_ref_counter == 0) public_data::destroy(p); } }; private: //! A pointer to the log record implementation intrusive_ptr< public_data > m_impl; private: // A private constructor, accessible from record explicit record_view(public_data* impl) BOOST_NOEXCEPT : m_impl(impl, false) {} #endif // BOOST_LOG_DOXYGEN_PASS public: /*! * Default constructor. Creates an empty record view that is equivalent to the invalid record handle. * * \post <tt>!*this == true</tt> */ BOOST_CONSTEXPR record_view() BOOST_NOEXCEPT #if !defined(BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS) && !defined(BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS) = default; #else {} #endif /*! * Copy constructor */ record_view(record_view const& that) BOOST_NOEXCEPT : m_impl(that.m_impl) {} /*! * Move constructor. Source record contents unspecified after the operation. */ record_view(BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT { m_impl.swap(that.m_impl); } /*! * Destructor. Destroys the record, releases any sinks and attribute values that were involved in processing this record. */ ~record_view() BOOST_NOEXCEPT {} /*! * Copy assignment */ record_view& operator= (BOOST_COPY_ASSIGN_REF(record_view) that) BOOST_NOEXCEPT { m_impl = that.m_impl; return *this; } /*! * Move assignment. Source record contents unspecified after the operation. */ record_view& operator= (BOOST_RV_REF(record_view) that) BOOST_NOEXCEPT { m_impl.swap(that.m_impl); return *this; } /*! * \return A reference to the set of attribute values attached to this record * * \pre <tt>!!*this</tt> */ attribute_value_set const& attribute_values() const BOOST_NOEXCEPT { return m_impl->m_attribute_values; } /*! * Equality comparison * * \param that Comparand * \return \c true if both <tt>*this</tt> and \a that identify the same log record or both do not * identify any record, \c false otherwise. */ bool operator== (record_view const& that) const BOOST_NOEXCEPT { return m_impl == that.m_impl; } /*! * Inequality comparison * * \param that Comparand * \return <tt>!(*this == that)</tt> */ bool operator!= (record_view const& that) const BOOST_NOEXCEPT { return !operator== (that); } /*! * Conversion to an unspecified boolean type * * \return \c true, if the <tt>*this</tt> identifies a log record, \c false, if the <tt>*this</tt> is not valid */ BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() /*! * Inverted conversion to an unspecified boolean type * * \return \c false, if the <tt>*this</tt> identifies a log record, \c true, if the <tt>*this</tt> is not valid */ bool operator! () const BOOST_NOEXCEPT { return !m_impl; } /*! * Swaps two handles * * \param that Another record to swap with * <b>Throws:</b> Nothing */ void swap(record_view& that) BOOST_NOEXCEPT { m_impl.swap(that.m_impl); } /*! * Resets the log record handle. If there are no other handles left, the log record is closed * and all resources referenced by the record are released. * * \post <tt>!*this == true</tt> */ void reset() BOOST_NOEXCEPT { m_impl.reset(); } /*! * Attribute value lookup. * * \param name Attribute name. * \return An \c attribute_value, non-empty if it is found, empty otherwise. */ attribute_value_set::mapped_type operator[] (attribute_value_set::key_type name) const { return m_impl->m_attribute_values[name]; } /*! * Attribute value lookup. * * \param keyword Attribute keyword. * \return A \c value_ref with extracted attribute value if it is found, empty \c value_ref otherwise. */ template< typename DescriptorT, template< typename > class ActorT > typename result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const& keyword) const { return m_impl->m_attribute_values[keyword]; } }; /*! * A free-standing swap function overload for \c record_view */ inline void swap(record_view& left, record_view& right) BOOST_NOEXCEPT { left.swap(right); } BOOST_LOG_CLOSE_NAMESPACE // namespace log } // namespace boost #include <boost/log/detail/footer.hpp> #endif // BOOST_LOG_CORE_RECORD_VIEW_HPP_INCLUDED_ record.hpp 0000644 00000013301 15125716360 0006537 0 ustar 00 /* * Copyright Andrey Semashev 2007 - 2015. * 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) */ /*! * \file record.hpp * \author Andrey Semashev * \date 09.03.2009 * * This header contains a logging record class definition. */ #ifndef BOOST_LOG_CORE_RECORD_HPP_INCLUDED_ #define BOOST_LOG_CORE_RECORD_HPP_INCLUDED_ #include <boost/move/core.hpp> #include <boost/core/explicit_operator_bool.hpp> #include <boost/log/detail/config.hpp> #include <boost/log/attributes/attribute_value_set.hpp> #include <boost/log/expressions/keyword_fwd.hpp> #include <boost/log/core/record_view.hpp> #include <boost/log/detail/header.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace boost { BOOST_LOG_OPEN_NAMESPACE class core; /*! * \brief Logging record class * * The logging record encapsulates all information related to a single logging statement, * in particular, attribute values view and the log message string. The record can be updated before pushing * for further processing to the logging core. */ class record { BOOST_MOVABLE_BUT_NOT_COPYABLE(record) friend class core; #ifndef BOOST_LOG_DOXYGEN_PASS private: //! Private data typedef record_view::public_data public_data; private: //! A pointer to the log record implementation public_data* m_impl; private: // A private constructor, accessible from core BOOST_CONSTEXPR explicit record(public_data* impl) BOOST_NOEXCEPT : m_impl(impl) {} #endif // BOOST_LOG_DOXYGEN_PASS public: /*! * Default constructor. Creates an empty record that is equivalent to the invalid record handle. * * \post <tt>!*this == true</tt> */ BOOST_CONSTEXPR record() BOOST_NOEXCEPT : m_impl(NULL) {} /*! * Move constructor. Source record contents unspecified after the operation. */ record(BOOST_RV_REF(record) that) BOOST_NOEXCEPT : m_impl(that.m_impl) { that.m_impl = NULL; } /*! * Destructor. Destroys the record, releases any sinks and attribute values that were involved in processing this record. */ ~record() BOOST_NOEXCEPT { reset(); } /*! * Move assignment. Source record contents unspecified after the operation. */ record& operator= (BOOST_RV_REF(record) that) BOOST_NOEXCEPT { swap(static_cast< record& >(that)); return *this; } /*! * \return A reference to the set of attribute values attached to this record * * \pre <tt>!!*this</tt> */ attribute_value_set& attribute_values() BOOST_NOEXCEPT { return m_impl->m_attribute_values; } /*! * \return A reference to the set of attribute values attached to this record * * \pre <tt>!!*this</tt> */ attribute_value_set const& attribute_values() const BOOST_NOEXCEPT { return m_impl->m_attribute_values; } /*! * Conversion to an unspecified boolean type * * \return \c true, if the <tt>*this</tt> identifies a log record, \c false, if the <tt>*this</tt> is not valid */ BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() /*! * Inverted conversion to an unspecified boolean type * * \return \c false, if the <tt>*this</tt> identifies a log record, \c true, if the <tt>*this</tt> is not valid */ bool operator! () const BOOST_NOEXCEPT { return !m_impl; } /*! * Swaps two handles * * \param that Another record to swap with * <b>Throws:</b> Nothing */ void swap(record& that) BOOST_NOEXCEPT { public_data* p = m_impl; m_impl = that.m_impl; that.m_impl = p; } /*! * Resets the log record handle. If there are no other handles left, the log record is closed * and all resources referenced by the record are released. * * \post <tt>!*this == true</tt> */ void reset() BOOST_NOEXCEPT { if (m_impl) { public_data::destroy(m_impl); m_impl = NULL; } } /*! * Attribute value lookup. * * \param name Attribute name. * \return An \c attribute_value, non-empty if it is found, empty otherwise. */ attribute_value_set::mapped_type operator[] (attribute_value_set::key_type name) const { return m_impl->m_attribute_values[name]; } /*! * Attribute value lookup. * * \param keyword Attribute keyword. * \return A \c value_ref with extracted attribute value if it is found, empty \c value_ref otherwise. */ template< typename DescriptorT, template< typename > class ActorT > typename result_of::extract< typename expressions::attribute_keyword< DescriptorT, ActorT >::value_type, DescriptorT >::type operator[] (expressions::attribute_keyword< DescriptorT, ActorT > const& keyword) const { return m_impl->m_attribute_values[keyword]; } /*! * The function ensures that the log record does not depend on any thread-specific data. Then the record contents * are used to construct a \c record_view which is returned from the function. The record is no longer valid after the call. * * \pre <tt>!!*this</tt> * \post <tt>!*this</tt> * \returns The record view that contains all attribute values from the original record. */ BOOST_LOG_API record_view lock(); }; /*! * A free-standing swap function overload for \c record */ inline void swap(record& left, record& right) BOOST_NOEXCEPT { left.swap(right); } BOOST_LOG_CLOSE_NAMESPACE // namespace log } // namespace boost #include <boost/log/detail/footer.hpp> #endif // BOOST_LOG_CORE_RECORD_HPP_INCLUDED_
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0.01 |
proxy
|
phpinfo
|
???????????