From 115f12d3b7a49cf9dcfbb1bff945da2d3e4dc591 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leroy Date: Tue, 22 Apr 2025 20:18:45 -0400 Subject: [PATCH] use nested namespace definitions everywhere, and reformat --- examples/headers_namespaces/dog.cpp | 4 ++-- examples/headers_namespaces/main_unrelated_namespaces.cpp | 2 +- include/boost/openmethod/compiler.hpp | 6 ++---- include/boost/openmethod/core.hpp | 3 ++- include/boost/openmethod/detail/ostdstream.hpp | 8 ++++---- include/boost/openmethod/detail/static_list.hpp | 8 ++++---- include/boost/openmethod/detail/trace.hpp | 7 +++---- include/boost/openmethod/detail/types.hpp | 7 +++---- include/boost/openmethod/policies/basic_error_output.hpp | 8 ++------ include/boost/openmethod/policies/basic_policy.hpp | 7 +++---- include/boost/openmethod/policies/basic_trace_output.hpp | 8 ++------ include/boost/openmethod/policies/fast_perfect_hash.hpp | 6 ++---- include/boost/openmethod/policies/minimal_rtti.hpp | 8 ++------ include/boost/openmethod/policies/std_rtti.hpp | 8 ++------ .../boost/openmethod/policies/vectored_error_handler.hpp | 8 ++------ include/boost/openmethod/policies/vptr_map.hpp | 8 ++------ include/boost/openmethod/policies/vptr_vector.hpp | 8 ++------ include/boost/openmethod/shared_ptr.hpp | 6 ++---- include/boost/openmethod/unique_ptr.hpp | 6 ++---- test/test_core.cpp | 8 ++------ test/test_shared_virtual_ptr_value_semantics.cpp | 6 ++---- test/test_virtual_ptr_dispatch.cpp | 1 - test/test_virtual_ptr_value_semantics.cpp | 6 ++---- test/test_virtual_ptr_value_semantics.hpp | 4 ++-- 24 files changed, 52 insertions(+), 99 deletions(-) diff --git a/examples/headers_namespaces/dog.cpp b/examples/headers_namespaces/dog.cpp index 93009fd..efb111b 100644 --- a/examples/headers_namespaces/dog.cpp +++ b/examples/headers_namespaces/dog.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "dog.hpp" @@ -12,4 +12,4 @@ BOOST_OPENMETHOD_DEFINE_OVERRIDER( os << dog->name << " barks"; } -} +} // namespace canines diff --git a/examples/headers_namespaces/main_unrelated_namespaces.cpp b/examples/headers_namespaces/main_unrelated_namespaces.cpp index eb7522e..5db86ff 100644 --- a/examples/headers_namespaces/main_unrelated_namespaces.cpp +++ b/examples/headers_namespaces/main_unrelated_namespaces.cpp @@ -18,6 +18,6 @@ BOOST_OPENMETHOD( using app_specific_behavior::BOOST_OPENMETHOD_GUIDE(meet); BOOST_OPENMETHOD_OVERRIDE( - meet, (std::ostream& os, virtual_ptr, virtual_ptr), void) { + meet, (std::ostream & os, virtual_ptr, virtual_ptr), void) { os << "ignore"; } diff --git a/include/boost/openmethod/compiler.hpp b/include/boost/openmethod/compiler.hpp index f69508e..625aae1 100644 --- a/include/boost/openmethod/compiler.hpp +++ b/include/boost/openmethod/compiler.hpp @@ -25,8 +25,7 @@ #include #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { namespace detail { template @@ -1320,7 +1319,6 @@ auto finalize() -> void { Policy::dispatch_data.clear(); } -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/core.hpp b/include/boost/openmethod/core.hpp index 2fcecc7..3898f05 100644 --- a/include/boost/openmethod/core.hpp +++ b/include/boost/openmethod/core.hpp @@ -741,7 +741,8 @@ class virtual_ptr : public detail::virtual_ptr_impl { if constexpr ( Policy::template has_facet && - Policy::template is_polymorphic && + Policy::template is_polymorphic< + typename impl::traits::virtual_type> && Policy::template is_polymorphic) { // check that dynamic type == static type auto static_type = Policy::template static_type(); diff --git a/include/boost/openmethod/detail/ostdstream.hpp b/include/boost/openmethod/detail/ostdstream.hpp index ed86bb1..66e332b 100644 --- a/include/boost/openmethod/detail/ostdstream.hpp +++ b/include/boost/openmethod/detail/ostdstream.hpp @@ -11,8 +11,8 @@ #include #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { + namespace detail { // ----------------------------------------------------------------------------- @@ -86,7 +86,7 @@ inline auto operator<<(ostdstream& os, std::size_t value) -> ostdstream& { } } // namespace detail -} // namespace openmethod -} // namespace boost + +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/detail/static_list.hpp b/include/boost/openmethod/detail/static_list.hpp index d495ff1..3175c96 100644 --- a/include/boost/openmethod/detail/static_list.hpp +++ b/include/boost/openmethod/detail/static_list.hpp @@ -9,8 +9,8 @@ #include #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { + namespace detail { template @@ -210,6 +210,6 @@ class static_list { }; } // namespace detail -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod + #endif diff --git a/include/boost/openmethod/detail/trace.hpp b/include/boost/openmethod/detail/trace.hpp index 24ef459..bac1c92 100644 --- a/include/boost/openmethod/detail/trace.hpp +++ b/include/boost/openmethod/detail/trace.hpp @@ -10,8 +10,8 @@ #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { + namespace detail { template @@ -158,7 +158,6 @@ auto operator<<(trace_type& trace, const type_name& manip) -> auto& { } } // namespace detail -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif // BOOST_OPENMETHOD_DETAIL_HPP diff --git a/include/boost/openmethod/detail/types.hpp b/include/boost/openmethod/detail/types.hpp index 248e467..c0d0aa7 100644 --- a/include/boost/openmethod/detail/types.hpp +++ b/include/boost/openmethod/detail/types.hpp @@ -10,8 +10,7 @@ #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { using type_id = std::uintptr_t; using vptr_type = const std::uintptr_t*; @@ -133,7 +132,7 @@ struct overrider_info : static_list::static_link { }; } // namespace detail -} // namespace openmethod -} // namespace boost + +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/policies/basic_error_output.hpp b/include/boost/openmethod/policies/basic_error_output.hpp index 7dafea0..b4c1933 100644 --- a/include/boost/openmethod/policies/basic_error_output.hpp +++ b/include/boost/openmethod/policies/basic_error_output.hpp @@ -9,9 +9,7 @@ #include #include -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { template struct basic_error_output : virtual error_output { @@ -21,8 +19,6 @@ struct basic_error_output : virtual error_output { template Stream basic_error_output::error_stream; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/policies/basic_policy.hpp b/include/boost/openmethod/policies/basic_policy.hpp index 1139158..e945ce2 100644 --- a/include/boost/openmethod/policies/basic_policy.hpp +++ b/include/boost/openmethod/policies/basic_policy.hpp @@ -14,8 +14,8 @@ #include #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { + namespace detail { using class_catalog = detail::static_list; @@ -130,7 +130,6 @@ struct basic_policy : abstract_policy, domain, Facets... { } // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/policies/basic_trace_output.hpp b/include/boost/openmethod/policies/basic_trace_output.hpp index d2ec7b4..0f6650e 100644 --- a/include/boost/openmethod/policies/basic_trace_output.hpp +++ b/include/boost/openmethod/policies/basic_trace_output.hpp @@ -15,9 +15,7 @@ #pragma warning(disable : 4996) #endif -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { template struct basic_trace_output : virtual trace_output { @@ -34,9 +32,7 @@ bool basic_trace_output::trace_enabled([]() { return env && *env++ == '1' && *env++ == 0; }()); -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #ifdef _MSC_VER #pragma warning(pop) diff --git a/include/boost/openmethod/policies/fast_perfect_hash.hpp b/include/boost/openmethod/policies/fast_perfect_hash.hpp index e30b588..36fe9c0 100644 --- a/include/boost/openmethod/policies/fast_perfect_hash.hpp +++ b/include/boost/openmethod/policies/fast_perfect_hash.hpp @@ -10,8 +10,7 @@ #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { namespace detail { @@ -187,7 +186,6 @@ template std::size_t fast_perfect_hash::hash_max; } // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/policies/minimal_rtti.hpp b/include/boost/openmethod/policies/minimal_rtti.hpp index 3264957..bc68202 100644 --- a/include/boost/openmethod/policies/minimal_rtti.hpp +++ b/include/boost/openmethod/policies/minimal_rtti.hpp @@ -8,9 +8,7 @@ #include -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { struct minimal_rtti : virtual rtti { template @@ -23,8 +21,6 @@ struct minimal_rtti : virtual rtti { } }; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/policies/std_rtti.hpp b/include/boost/openmethod/policies/std_rtti.hpp index efd5921..2444c80 100644 --- a/include/boost/openmethod/policies/std_rtti.hpp +++ b/include/boost/openmethod/policies/std_rtti.hpp @@ -14,9 +14,7 @@ #include #endif -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { struct std_rtti : virtual rtti { #ifndef BOOST_NO_RTTI @@ -52,8 +50,6 @@ struct std_rtti : virtual rtti { #endif }; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/policies/vectored_error_handler.hpp b/include/boost/openmethod/policies/vectored_error_handler.hpp index d58a500..d1a8eea 100644 --- a/include/boost/openmethod/policies/vectored_error_handler.hpp +++ b/include/boost/openmethod/policies/vectored_error_handler.hpp @@ -11,9 +11,7 @@ #include #include -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { template class vectored_error_handler : public error_handler { @@ -83,8 +81,6 @@ typename vectored_error_handler::function_type vectored_error_handler::fn = vectored_error_handler::default_handler; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/policies/vptr_map.hpp b/include/boost/openmethod/policies/vptr_map.hpp index dde2d1b..9798023 100644 --- a/include/boost/openmethod/policies/vptr_map.hpp +++ b/include/boost/openmethod/policies/vptr_map.hpp @@ -10,9 +10,7 @@ #include -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { template< class Policy, class Facet = void, @@ -84,8 +82,6 @@ class vptr_map : public extern_vptr, template Map vptr_map::vptrs; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/policies/vptr_vector.hpp b/include/boost/openmethod/policies/vptr_vector.hpp index 4d12071..d77489e 100644 --- a/include/boost/openmethod/policies/vptr_vector.hpp +++ b/include/boost/openmethod/policies/vptr_vector.hpp @@ -11,9 +11,7 @@ #include #include -namespace boost { -namespace openmethod { -namespace policies { +namespace boost::openmethod::policies { template class vptr_vector : public extern_vptr, @@ -95,8 +93,6 @@ template std::vector::element_type> vptr_vector::vptrs; -} // namespace policies -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod::policies #endif diff --git a/include/boost/openmethod/shared_ptr.hpp b/include/boost/openmethod/shared_ptr.hpp index df2263b..427524a 100644 --- a/include/boost/openmethod/shared_ptr.hpp +++ b/include/boost/openmethod/shared_ptr.hpp @@ -9,8 +9,7 @@ #include #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { namespace detail { template @@ -125,7 +124,6 @@ inline auto make_shared_virtual(T&&... args) std::make_shared(std::forward(args)...)); } -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif diff --git a/include/boost/openmethod/unique_ptr.hpp b/include/boost/openmethod/unique_ptr.hpp index c303a3c..f5bbb72 100644 --- a/include/boost/openmethod/unique_ptr.hpp +++ b/include/boost/openmethod/unique_ptr.hpp @@ -10,8 +10,7 @@ #include -namespace boost { -namespace openmethod { +namespace boost::openmethod { template struct virtual_traits, Policy> { @@ -47,7 +46,6 @@ inline auto make_unique_virtual(T&&... args) std::make_unique(std::forward(args)...)); } -} // namespace openmethod -} // namespace boost +} // namespace boost::openmethod #endif diff --git a/test/test_core.cpp b/test/test_core.cpp index 1a5d45c..526a4f3 100644 --- a/test/test_core.cpp +++ b/test/test_core.cpp @@ -325,9 +325,7 @@ namespace test_static_slots { struct Animal; } -namespace boost { -namespace openmethod { -namespace detail { +namespace boost::openmethod::detail { template<> struct static_offsets, Dog>); - static_assert( - !construct_assign_ok, Dog&&>); + static_assert(!construct_assign_ok, Dog>); + static_assert(!construct_assign_ok, Dog&&>); static_assert( !construct_assign_ok, const Dog&>); static_assert( diff --git a/test/test_virtual_ptr_dispatch.cpp b/test/test_virtual_ptr_dispatch.cpp index 267dc31..50fc5c7 100644 --- a/test/test_virtual_ptr_dispatch.cpp +++ b/test/test_virtual_ptr_dispatch.cpp @@ -169,7 +169,6 @@ BOOST_AUTO_TEST_CASE(test_virtual_ptr_non_polymorphic) { } // namespace using_non_polymorphic_classes - struct Player { virtual ~Player() { } diff --git a/test/test_virtual_ptr_value_semantics.cpp b/test/test_virtual_ptr_value_semantics.cpp index 98b15e2..97382d4 100644 --- a/test/test_virtual_ptr_value_semantics.cpp +++ b/test/test_virtual_ptr_value_semantics.cpp @@ -239,10 +239,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(plain_virtual_ptr_value, Policy, test_policies) { BOOST_TEST(p.vptr() == nullptr); } - static_assert( - !construct_assign_ok, const Dog&>); - static_assert( - !construct_assign_ok, const Dog*>); + static_assert(!construct_assign_ok, const Dog&>); + static_assert(!construct_assign_ok, const Dog*>); } BOOST_AUTO_TEST_CASE_TEMPLATE(indirect_virtual_ptr, Policy, test_policies) { diff --git a/test/test_virtual_ptr_value_semantics.hpp b/test/test_virtual_ptr_value_semantics.hpp index 1e148bf..8a95d09 100644 --- a/test/test_virtual_ptr_value_semantics.hpp +++ b/test/test_virtual_ptr_value_semantics.hpp @@ -77,8 +77,8 @@ struct check_illegal_smart_ops { static_assert(!std::is_constructible_v< virtual_ptr, Policy>, Animal*>); - static_assert( - !std::is_constructible_v, const other_smart_ptr&>); + static_assert(!std::is_constructible_v< + smart_ptr, const other_smart_ptr&>); // smart_ptr p{other_smart_ptr()}; static_assert(!std::is_constructible_v<