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