diff --git a/doc/pfr.qbk b/doc/pfr.qbk index ef1a8d4..d5adc48 100644 --- a/doc/pfr.qbk +++ b/doc/pfr.qbk @@ -112,7 +112,10 @@ template struct uniform_comparator_less { bool operator()(const T& lhs, const T& rhs) const noexcept { using namespace boost::pfr::ops; // Enables Boost.PFR operators usage in this scope. - return lhs < rhs; // If T has operator< or conversion operator then will use it, otherwise will use boost::pfr::flat_less. + + // If T has operator< or conversion operator then will use it. + // Otherwise will use boost::pfr::flat_less. + return lhs < rhs; } }; ``` @@ -125,7 +128,10 @@ template struct uniform_comparator_less { bool operator()(const T& lhs, const T& rhs) const noexcept { using namespace flat_ops; - return std::less{}(lhs, rhs); // Compile time error if T has neither operator< nor conversion operator to comparable type. + + // Compile time error if T has neither operator< nor + // conversion operator to comparable type. + return std::less{}(lhs, rhs); } }; ``` @@ -215,8 +221,10 @@ bool some_function(foo f1, foo f2) { Any attempt to reflect unions leads to a compile time error. In many cases a static assert is triggered that outputs the following message: ``` -error: static_assert failed "====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info." +error: static_assert failed "====================> Boost.PFR: For safety reasons it is forbidden + to reflect unions. See `Reflection of unions` section in the docs for more info." ``` + [endsect] [endsect] @@ -236,83 +244,83 @@ Following examples use definition from above: [ [pfr_quick_examples_flat_functors_uset] ] [ `my_uset` constains `var` ] [ - [classref boost::pfr::flat_hash] - - [classref boost::pfr::flat_equal_to] + [classref boost::pfr::flat_hash flat_hash] + + [classref boost::pfr::flat_equal_to flat_equal_to] ] ][ [ [pfr_quick_examples_flat_functors_set] ] [ `my_set` constains `var` ] - [ [classref boost::pfr::flat_less] ] + [ [classref boost::pfr::flat_less flat_less] ] ][ [ [pfr_quick_examples_flat_ops] ] [ assert succeeds ] - [ [headerref boost/pfr/flat/ops.hpp using\u00A0namespace\u00A0boost::pfr::flat_ops;] ] + [ [headerref boost/pfr/flat/ops.hpp using\u00A0namespace\u00A0flat_ops;] ] ][ [ [pfr_quick_examples_ops] ] [ assert succeeds ] - [ [headerref boost/pfr/precise/ops.hpp using\u00A0namespace\u00A0boost::pfr::ops;] ] + [ [headerref boost/pfr/precise/ops.hpp using\u00A0namespace\u00A0ops;] ] ][ [ [pfr_quick_examples_flat_for_each] ] [ `var == {B, {778, 4.14159}}` ] - [ [funcref boost::pfr::flat_for_each_field] ] + [ [funcref boost::pfr::flat_for_each_field flat_for_each_field] ] ][ [ [pfr_quick_examples_for_each] ] [ `var == {B, {787, 103.142}}` ] - [ [funcref boost::pfr::for_each_field] ] + [ [funcref boost::pfr::for_each_field for_each_field] ] ][ [ [pfr_quick_examples_flat_for_each_idx] ] [ ```0: char 1: int 2: double ``` ] - [ [funcref boost::pfr::flat_for_each_field] ] + [ [funcref boost::pfr::flat_for_each_field flat_for_each_field] ] ][ [ [pfr_quick_examples_for_each_idx] ] [ ```0: char 1: quick_examples_ns::foo ``` ] - [ [funcref boost::pfr::for_each_field] ] + [ [funcref boost::pfr::for_each_field for_each_field] ] ][ [ [pfr_quick_examples_tuple_size] ] [ `tuple_size: 2` ] - [ [classref boost::pfr::tuple_size] ] + [ [classref boost::pfr::tuple_size tuple_size] ] ][ [ [pfr_quick_examples_flat_tuple_size] ] [ `flat_tuple_size: 3` ] - [ [classref boost::pfr::flat_tuple_size] ] + [ [classref boost::pfr::flat_tuple_size flat_tuple_size] ] ][ [ [pfr_quick_examples_get_1] ] [ `var == {A {1, 2.0}}` ] - [ [funcref boost::pfr::get] ] + [ [funcref boost::pfr::get get] ] ][ [ [pfr_quick_examples_flat_get_1] ] [ `var == {A, {1, 3.14159}}` ] - [ [funcref boost::pfr::flat_get] ] + [ [funcref boost::pfr::flat_get flat_get] ] ][ [ [pfr_quick_examples_get_2] ] [ `var == {A, {777, 42.01}}` ] - [ [funcref boost::pfr::get] ] + [ [funcref boost::pfr::get get] ] ][ [ [pfr_quick_examples_flat_get_2] ] [ `var == {A, {777, 42.01}}` ] - [ [funcref boost::pfr::flat_get] ] + [ [funcref boost::pfr::flat_get flat_get] ] ][ [ [pfr_quick_examples_structure_to_tuple] ] [ `var == {A, {777, 3.14159}}` ] - [ [funcref boost::pfr::structure_to_tuple] ] + [ [funcref boost::pfr::structure_to_tuple structure_to_tuple] ] ][ [ [pfr_quick_examples_flat_structure_to_tuple] ] [ `var == {A, {777, 3.14159}}` ] - [ [funcref boost::pfr::flat_structure_to_tuple] ] + [ [funcref boost::pfr::flat_structure_to_tuple flat_structure_to_tuple] ] ][ [ [pfr_quick_examples_structure_tie] ] [ `var == {A, {1, 2.0}}` ] - [ [funcref boost::pfr::structure_tie] ] + [ [funcref boost::pfr::structure_tie structure_tie] ] ][ [ [pfr_quick_examples_flat_structure_tie] ] [ `var == {C, {777, 3.14159}}` ] - [ [funcref boost::pfr::flat_structure_tie] ] + [ [funcref boost::pfr::flat_structure_tie flat_structure_tie] ] ]] diff --git a/example/quick_examples.cpp b/example/quick_examples.cpp index cafedd5..b9e2e1e 100644 --- a/example/quick_examples.cpp +++ b/example/quick_examples.cpp @@ -42,7 +42,9 @@ void test_examples() { //[pfr_quick_examples_flat_functors_uset // no `std::hash` or `bar::operator==(const bar&)` defined - std::unordered_set, boost::pfr::flat_equal_to<>> my_uset; + std::unordered_set< + bar, boost::pfr::flat_hash, + boost::pfr::flat_equal_to<>> my_uset; my_uset.insert(var); //] } @@ -92,7 +94,7 @@ void test_examples() { bar var{'A', {777, 3.141593}}; //[pfr_quick_examples_for_each - // incrementing first field on 1 and calling foo::operator+= for second field: + // increments first field on 1, calls foo::operator+= for second field boost::pfr::for_each_field(var, [](auto& field) { field += 1; }); @@ -108,8 +110,9 @@ void test_examples() { bar var{'A', {777, 3.141593}}; //[pfr_quick_examples_flat_for_each_idx - boost::pfr::flat_for_each_field(var, [](const auto& field, std::size_t idx) { - std::cout << idx << ": " << boost::typeindex::type_id_runtime(field) << '\n'; + boost::pfr::flat_for_each_field(var, [](auto& field, std::size_t idx) { + std::cout << idx << ": " + << boost::typeindex::type_id_runtime(field) << '\n'; }); //] } @@ -118,8 +121,9 @@ void test_examples() { bar var{'A', {777, 3.141593}}; //[pfr_quick_examples_for_each_idx - boost::pfr::for_each_field(var, [](const auto& field, std::size_t idx) { - std::cout << idx << ": " << boost::typeindex::type_id_runtime(field) << '\n'; + boost::pfr::for_each_field(var, [](auto& field, std::size_t idx) { + std::cout << idx << ": " + << boost::typeindex::type_id_runtime(field) << '\n'; }); //] } @@ -127,13 +131,15 @@ void test_examples() { { //[pfr_quick_examples_tuple_size - std::cout << "tuple_size: " << boost::pfr::tuple_size::value << '\n'; + std::cout << "tuple_size: " + << boost::pfr::tuple_size::value << '\n'; //] } { //[pfr_quick_examples_flat_tuple_size - std::cout << "flat_tuple_size: " << boost::pfr::flat_tuple_size::value << '\n'; + std::cout << "flat_tuple_size: " + << boost::pfr::flat_tuple_size::value << '\n'; //] } @@ -176,7 +182,8 @@ void test_examples() { { bar var{'A', {777, 3.141593}}; //[pfr_quick_examples_structure_to_tuple - std::tuple t = boost::pfr::structure_to_tuple(var); // C++17 is required + // C++17 is required + std::tuple t = boost::pfr::structure_to_tuple(var); std::get<1>(t) = foo{1, 2}; //] std::cout << "boost::pfr::structure_to_tuple(var) :\n" << var << '\n'; @@ -196,7 +203,8 @@ void test_examples() { { bar var{'A', {777, 3.141593}}; //[pfr_quick_examples_structure_tie - std::tuple t = boost::pfr::structure_tie(var); // C++17 is required + // C++17 is required + std::tuple t = boost::pfr::structure_tie(var); std::get<1>(t) = foo{1, 2}; //] std::cout << "boost::pfr::structure_tie(var) :\n" << var << '\n'; diff --git a/include/boost/pfr/flat/tuple_size.hpp b/include/boost/pfr/flat/tuple_size.hpp index 87697a4..e830239 100644 --- a/include/boost/pfr/flat/tuple_size.hpp +++ b/include/boost/pfr/flat/tuple_size.hpp @@ -16,7 +16,7 @@ namespace boost { namespace pfr { -/// \brief Has a static const member variable `value` that contains fields count in a \flattening{flattened} T. +/// Has a static const member variable `value` that contains fields count in a \flattening{flattened} T. /// /// \b Example: /// \code @@ -26,7 +26,7 @@ template using flat_tuple_size = boost::pfr::detail::size_t_()))::size_v>; -/// \brief `flat_tuple_size_v` is a template variable that contains fields count in a \flattening{flattened} T. +/// `flat_tuple_size_v` is a template variable that contains fields count in a \flattening{flattened} T. /// /// \b Example: /// \code diff --git a/include/boost/pfr/precise/tuple_size.hpp b/include/boost/pfr/precise/tuple_size.hpp index 1df951d..fb637b5 100644 --- a/include/boost/pfr/precise/tuple_size.hpp +++ b/include/boost/pfr/precise/tuple_size.hpp @@ -18,7 +18,7 @@ namespace boost { namespace pfr { -/// \brief Has a static const member variable `value` that contains fields count in a T. +/// Has a static const member variable `value` that contains fields count in a T. /// Works for any T that supports aggregate initialization even if T is not POD. /// \flattening{Flattens} only multidimensional arrays. /// @@ -32,7 +32,7 @@ template using tuple_size = detail::size_t_< boost::pfr::detail::fields_count() >; -/// \brief `tuple_size_v` is a template variable that contains fields count in a T and +/// `tuple_size_v` is a template variable that contains fields count in a T and /// works for any T that supports aggregate initialization even if T is not POD. /// \flattening{Flattens} only multidimensional arrays. ///