Skip to content

Commit 2a1f885

Browse files
committed
refinements plus workaround for compile-time type name hash computation on older gcc versions
1 parent 83182ca commit 2a1f885

File tree

14 files changed

+22
-26
lines changed

14 files changed

+22
-26
lines changed

include/boost/leaf/common.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

88
#include <boost/leaf/config.hpp>
9-
#include <boost/leaf/detail/demangle.hpp>
109

1110
#include <iosfwd>
1211
#include <cerrno>

include/boost/leaf/detail/demangle.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace n
182182
// Unrecognized __PRETTY_FUNCTION__/__FUNCSIG__ formats will result in compiler diagnostics.
183183
// In that case, please file an issue on https://github.com/boostorg/leaf.
184184

185-
#define BOOST_LEAF_P(P) (sizeof(char[1 + detail::check_prefix(BOOST_LEAF_PRETTY_FUNCTION, P)]) - 1)
185+
#define BOOST_LEAF_P(P) (sizeof(char[1 + detail::check_prefix(BOOST_LEAF_PRETTY_FUNCTION, (P))]) - 1)
186186
// clang style:
187187
std::size_t const p01 = BOOST_LEAF_P("r boost::leaf::n::p() [T = ");
188188
std::size_t const p02 = BOOST_LEAF_P("r __cdecl boost::leaf::n::p(void) [T = ");
@@ -216,7 +216,7 @@ namespace n
216216
std::size_t const p24 = BOOST_LEAF_P("struct boost::leaf::n::r __fastcall boost::leaf::n::p<");
217217
#undef BOOST_LEAF_P
218218

219-
#define BOOST_LEAF_S(S) (sizeof(char[1 + detail::check_suffix(BOOST_LEAF_PRETTY_FUNCTION, S)]) - 1)
219+
#define BOOST_LEAF_S(S) (sizeof(char[1 + detail::check_suffix(BOOST_LEAF_PRETTY_FUNCTION, (S))]) - 1)
220220
// clang/gcc style:
221221
std::size_t const s01 = BOOST_LEAF_S("]");
222222
// msvc style:
@@ -234,14 +234,16 @@ namespace n
234234
) * 2 - 1];
235235
(void) static_assert_unrecognized_pretty_function_format_please_file_github_issue;
236236

237+
#define BOOST_LEAF_COMPUTE_TYPE_HASH(P, S) detail::compute_hash<sizeof(char[(1 + (P))]) - 1, sizeof(char[(1 + (S))]) - 1>(BOOST_LEAF_PRETTY_FUNCTION)
237238
if( std::size_t const p = sizeof(char[1 + !!s01 * (p01 + p02 + p03 + p04 + p05 + p06 + p07 + p08 + p09 + p10 + p11 + p12)]) - 1 )
238-
return { BOOST_LEAF_PRETTY_FUNCTION + p, s01 - p, detail::compute_hash<p, s01>(BOOST_LEAF_PRETTY_FUNCTION) };
239+
return { BOOST_LEAF_PRETTY_FUNCTION + p, s01 - p, BOOST_LEAF_COMPUTE_TYPE_HASH(p, s01) };
239240

240241
if( std::size_t const p = sizeof(char[1 + !!s02 * (p13 + p14 + p15 + p16 + p17 + p18 + p19 + p20 + p21)]) - 1 )
241-
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, detail::compute_hash<p, s02>(BOOST_LEAF_PRETTY_FUNCTION) };
242+
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, BOOST_LEAF_COMPUTE_TYPE_HASH(p, s02) };
242243

243-
std::size_t const p = sizeof(char[1 + !!s02 * (p22 + p23 + p24)]) - 1; // p is not zero, we've static asserted the hell out of it
244-
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, detail::compute_hash<p, s02>(BOOST_LEAF_PRETTY_FUNCTION) };
244+
std::size_t const p = sizeof(char[1 + !!s02 * (p22 + p23 + p24)]) - 1;
245+
return { BOOST_LEAF_PRETTY_FUNCTION + p, s02 - p, BOOST_LEAF_COMPUTE_TYPE_HASH(p, s02) };
246+
#undef BOOST_LEAF_COMPUTE_TYPE_HASH
245247
}
246248
} // namespace n
247249

include/boost/leaf/detail/exception_base.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Distributed under the Boost Software License, Version 1.0. (See accompanying
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

8+
#include <boost/leaf/config.hpp>
89
#include <boost/leaf/detail/demangle.hpp>
910

1011
namespace boost { namespace leaf {

include/boost/leaf/detail/function_traits.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Distributed under the Boost Software License, Version 1.0. (See accompanying
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

8+
#include <boost/leaf/config.hpp>
89
#include <boost/leaf/detail/mp11.hpp>
910

1011
#include <tuple>

include/boost/leaf/error.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <boost/leaf/detail/capture_list.hpp>
1212
#include <boost/leaf/serialization/diagnostics_writer.hpp>
1313

14-
#include <cstring>
15-
1614
#if BOOST_LEAF_CFG_STD_SYSTEM_ERROR
1715
# include <system_error>
1816
#endif

include/boost/leaf/serialization/diagnostics_writer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Distributed under the Boost Software License, Version 1.0. (See accompanying
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

8+
#include <boost/leaf/config.hpp>
89
#include <boost/leaf/serialization/writer.hpp>
910
#include <boost/leaf/detail/exception_base.hpp>
1011

include/boost/leaf/serialization/json_writer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Distributed under the Boost Software License, Version 1.0. (See accompanying
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

8+
#include <boost/leaf/config.hpp>
89
#include <boost/leaf/serialization/writer.hpp>
910
#include <boost/leaf/detail/exception_base.hpp>
1011
#include <boost/leaf/error.hpp>

include/boost/leaf/serialization/writer.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Distributed under the Boost Software License, Version 1.0. (See accompanying
66
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

8+
#include <boost/leaf/config.hpp>
89
#include <boost/leaf/detail/demangle.hpp>
910

1011
#include <type_traits>
@@ -37,14 +38,14 @@ class writer
3738
{
3839
return type_ == parse<typename std::decay<Derived>::type>() ? static_cast<Derived *>(this) : nullptr;
3940
}
40-
}; // class writer
41+
};
4142

42-
template <class W, class E>
43-
typename std::enable_if<std::is_base_of<writer, W>::value>::type
44-
serialize(W &, E const &)
45-
{
43+
template <class W, class E>
44+
typename std::enable_if<std::is_base_of<writer, W>::value>::type
45+
serialize(W &, E const &)
46+
{
47+
}
4648
}
47-
} // namespace serialization
4849

4950
namespace detail
5051
{
@@ -53,7 +54,7 @@ namespace detail
5354
{
5455
using type = serialization::writer;
5556
};
56-
} // namespace detail
57+
}
5758

5859
} } // namespace boost::leaf
5960

test/diagnostics_test6.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#else
88
# include <boost/leaf/config.hpp>
99
# include <boost/leaf/diagnostics.hpp>
10-
# include <boost/leaf/on_error.hpp>
1110
# include <boost/leaf/result.hpp>
1211
#endif
1312

test/error_code_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ int main()
1919
#ifdef BOOST_LEAF_TEST_SINGLE_HEADER
2020
# include "leaf.hpp"
2121
#else
22-
# include <boost/leaf/diagnostics.hpp>
2322
# include <boost/leaf/pred.hpp>
2423
# include <boost/leaf/result.hpp>
2524
#endif

0 commit comments

Comments
 (0)