//Copyright (c) 2006-2026 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_EXCEPTION_DETAIL_ENCODER_HPP_INCLUDED #define BOOST_EXCEPTION_DETAIL_ENCODER_HPP_INCLUDED #include #include #include namespace boost { template class error_info; namespace exception_serialization { struct encoder_adl {}; } namespace exception_detail { template struct first_arg; template struct first_arg { using type = A1; }; template struct first_arg { using type = A1; }; class encoder: exception_serialization::encoder_adl { encoder(encoder const &) = delete; encoder & operator=(encoder const &) = delete; core::typeinfo const * type_; void * e_; bool dispatch_() { return false; } template bool dispatch_(F1 && f1, Fn && ... fn) { using encoder_type = typename std::decay::type::operator())>::type>::type; if (encoder_type * e = get()) { std::forward(f1)(*e); return true; } return dispatch_(std::forward(fn)...); } protected: template explicit encoder(Encoder * e) noexcept: type_(&BOOST_CORE_TYPEID(Encoder)), e_(e) { } public: template Encoder * get() noexcept { return *type_ == BOOST_CORE_TYPEID(Encoder) ? static_cast(e_) : nullptr; } template bool dispatch(Fn && ... fn) { return dispatch_(std::forward(fn)...); } }; template struct encoder_adaptor: encoder { explicit encoder_adaptor(Encoder & e) noexcept: encoder(&e) { } }; } } #endif