2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

Fix docs rendering on narrow screens

This commit is contained in:
Antony Polukhin
2019-07-28 12:44:08 +03:00
parent 72df78ad28
commit 449d6769a2
4 changed files with 53 additions and 37 deletions

View File

@@ -112,7 +112,10 @@ template <class T>
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<T>.
// If T has operator< or conversion operator then will use it.
// Otherwise will use boost::pfr::flat_less<T>.
return lhs < rhs;
}
};
```
@@ -125,7 +128,10 @@ template <class T>
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] ]
]]

View File

@@ -42,7 +42,9 @@ void test_examples() {
//[pfr_quick_examples_flat_functors_uset
// no `std::hash<bar>` or `bar::operator==(const bar&)` defined
std::unordered_set<bar, boost::pfr::flat_hash<bar>, boost::pfr::flat_equal_to<>> my_uset;
std::unordered_set<
bar, boost::pfr::flat_hash<bar>,
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<bar>::value << '\n';
std::cout << "tuple_size: "
<< boost::pfr::tuple_size<bar>::value << '\n';
//]
}
{
//[pfr_quick_examples_flat_tuple_size
std::cout << "flat_tuple_size: " << boost::pfr::flat_tuple_size<bar>::value << '\n';
std::cout << "flat_tuple_size: "
<< boost::pfr::flat_tuple_size<bar>::value << '\n';
//]
}
@@ -176,7 +182,8 @@ void test_examples() {
{
bar var{'A', {777, 3.141593}};
//[pfr_quick_examples_structure_to_tuple
std::tuple<char, foo> t = boost::pfr::structure_to_tuple(var); // C++17 is required
// C++17 is required
std::tuple<char, foo> 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<char&, foo&> t = boost::pfr::structure_tie(var); // C++17 is required
// C++17 is required
std::tuple<char&, foo&> t = boost::pfr::structure_tie(var);
std::get<1>(t) = foo{1, 2};
//]
std::cout << "boost::pfr::structure_tie(var) :\n" << var << '\n';

View File

@@ -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 <class T>
using flat_tuple_size = boost::pfr::detail::size_t_<decltype(boost::pfr::detail::tie_as_flat_tuple(std::declval<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

View File

@@ -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 <class T>
using tuple_size = detail::size_t_< boost::pfr::detail::fields_count<T>() >;
/// \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.
///