Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ jobs:
git submodule init libs/type_traits
git submodule init libs/typeof
git submodule init libs/utility
git submodule init libs/pfr
git submodule init libs/mp11
git submodule init libs/headers tools/boost_install tools/build
git submodule update
rm -rf libs/fusion
Expand Down Expand Up @@ -452,6 +454,8 @@ jobs:
git submodule init libs/type_traits
git submodule init libs/typeof
git submodule init libs/utility
git submodule init libs/pfr
git submodule init libs/mp11
git submodule init libs/headers tools/boost_install tools/build
git submodule update
rm -rf libs/fusion
Expand All @@ -464,4 +468,4 @@ jobs:

./b2 -j`(nproc || sysctl -n hw.ncpu) 2> /dev/null` libs/fusion/test toolset=$TOOLSET cxxstd=$CXXSTD

fi
fi
2 changes: 2 additions & 0 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ target_link_libraries(boost_fusion
Boost::type_traits
Boost::typeof
Boost::utility
Boost::pfr
Boost::mp11
Boost::functional
)
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ install:
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/utility
- git submodule init libs/pfr
- git submodule init libs/mp11

- git submodule init libs/headers tools/boost_install tools/build
- git submodule update
Expand Down
128 changes: 128 additions & 0 deletions doc/algorithm.qbk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 Dan Marsden
Copyright (C) 2010 Christopher Schmidt
Copyright (c) 2022 Denis Mikhailov

Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -139,6 +140,91 @@ Linear, exactly `__result_of_size__<Sequence>::value`.

[endsect]

[section pfr_fields]

[caution This function requires at least C++14! Pre C++14 compilers (C++11, C++03...) are not supported.]

[heading Description]
For an user defined structure `agg`, `pfr_fields` returns a new sequence
with elements extracted by using __boost_pfr__.
This function does not require macro or boilerplate code from an user defined structure
, unlike __adapt_struct__, and can be used as a replacement for __adapt_struct__.

[heading Synopsis]
template<
typename Aggregate
>
typename __result_of_pfr_fields__<Aggregate>::type pfr_fields(
Aggregate& agg);

template<
typename Aggregate
>
typename __result_of_pfr_fields__<Aggregate const>::type pfr_fields(
Aggregate const& agg);

[table Parameters
[[Parameter][Requirement][Description]]
[[`agg`][A model of __simple_aggregate__][Operation's argument]]
]

[heading Expression Semantics]
__pfr_fields__(agg);

[*Return type]: A model of __random_access_sequence__

[*Semantics]: Returns a sequence with all elements from user defined structure.

[heading Complexity]
Constant.

[heading Header]

#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
#include <boost/fusion/include/pfr_fields.hpp>

[note This algorithm won't be defined by inclusion of 'boost/fusion/algorithm/auxiliary.hpp' or 'boost/fusion/algorithm.hpp'. ]

[heading Example]

struct some_person { // SimpleAggregate
std::string name;
unsigned birth_year = 0;
};

some_person val{"Edgar Allan Poe", 1809};
std::cout << __pfr_fields__(val) << std::endl; // (Edgar Allan Poe 1809)

[heading Example]

struct empty { // SimpleAggregate
};

struct aggregate : empty { // not a SimpleAggregate because of inheritance
std::string name;
int age = 0;
boost::uuids::uuid uuid;
};

aggregate val{"Edgar Allan Poe", 1809, {}};
__pfr_fields__(val); // non-portable behavior

[heading Example]

using some_person = __vector__< // not a SimpleAggregate
std::string
, unsigned
>;

some_person val("Edgar Allan Poe", 1809);
__pfr_fields__(val); // won't compile

[heading See also]

__boost_pfr__

[endsect]

[endsect]

[section Metafunctions]
Expand Down Expand Up @@ -215,6 +301,48 @@ Constant.

[endsect]

[section pfr_fields]

[caution This metafunction requires at least C++14! Pre C++14 compilers (C++11, C++03...) are not supported.]

[heading Description]
A metafunction returning the result type of applying __pfr_fields__.

[heading Synopsis]
template <typename Aggregate>
struct pfr_fields
{
typedef __unspecified__ type;
};

[table Parameters
[[Parameter] [Requirement] [Description]]
[[`Aggregate`] [A model of __simple_aggregate__] [Operation's argument]]
]

[heading Expression Semantics]
result_of::pfr_fields<Aggregate>::type

[*Return type]: A model of __random_access_sequence__

[*Semantics]: Returns a sequence with all elements from user defined structure.

[heading Complexity]
Constant.

[heading Header]

#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
#include <boost/fusion/include/pfr_fields.hpp>

[note This algorithm won't be defined by inclusion of 'boost/fusion/algorithm/auxiliary.hpp' or 'boost/fusion/algorithm.hpp'. ]

[heading See also]

__boost_pfr__

[endsect]

[endsect]

[endsect]
Expand Down
7 changes: 7 additions & 0 deletions doc/fusion.qbk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
[def __boost_func_forward__ [@http://www.boost.org/libs/functional/forward Boost.Functional/Forward Library]]
[def __boost_func_factory__ [@http://www.boost.org/libs/functional/factory Boost.Functional/Factory Library]]
[def __boost_func_hash__ [@http://www.boost.org/doc/html/hash.html Boost.ContainerHash Library]]
[def __boost_pfr__ [@http://www.boost.org/doc/html/boost_pfr.html Boost.PFR Library]]
[def __boost_pfr_lims__ [@http://www.boost.org/doc/html/boost_pfr/limitations_and_configuration.html Boost.PFR Limitations and Configuration]]
[def __simple_aggregate__ [@http://www.boost.org/doc/html/boost_pfr/limitations_and_configuration.html SimpleAggregate]]
[def __std_pair_doc__ [@http://en.cppreference.com/w/cpp/utility/pair `std::pair`]]
[def __std_tuple_doc__ [@http://en.cppreference.com/w/cpp/utility/tuple `std::tuple`]]
[def __std_plus_doc__ [@http://en.cppreference.com/w/cpp/utility/functional/plus `std::plus`]]
Expand Down Expand Up @@ -131,12 +134,14 @@
[def __zip_view__ [link fusion.view.zip_view `zip_view`]]
[def __flatten_view__ [link fusion.view.flatten_view `flatten_view`]]
[def __identity_view__ [link fusion.view.identity_view `identity_view`]]
[def __pfr_fields_view__ [link fusion.view.pfr_fields_view `pfr_fields_view`]]

[def __array__ [link fusion.adapted.array array]]
[def __std_pair__ [link fusion.adapted.std__pair `std::pair`]]
[def __boost_array__ [link fusion.adapted.boost__array `boost::array`]]
[def __mpl_sequence__ [link fusion.adapted.mpl_sequence mpl sequence]]
[def __adapt_tpl_struct__ [link fusion.adapted.adapt_tpl_struct `BOOST_FUSION_ADAPT_TPL_STRUCT`]]
[def __adapt_struct__ [link fusion.adapted.adapt_struct `BOOST_FUSION_ADAPT_STRUCT`]]
[def __adapt_struct_named__ [link fusion.adapted.adapt_struct_named `BOOST_FUSION_ADAPT_STRUCT_NAMED`]]
[def __adapt_struct_named_ns__ [link fusion.adapted.adapt_struct_named `BOOST_FUSION_ADAPT_STRUCT_NAMED_NS`]]
[def __adapt_assoc_tpl_struct__ [link fusion.adapted.adapt_assoc_tpl_struct `BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT`]]
Expand Down Expand Up @@ -229,6 +234,8 @@
[def __result_of_copy__ [link fusion.algorithm.auxiliary.metafunctions.copy `result_of::copy`]]
[def __move__ [link fusion.algorithm.auxiliary.functions.move `move`]]
[def __result_of_move__ [link fusion.algorithm.auxiliary.metafunctions.move `result_of::move`]]
[def __pfr_fields__ [link fusion.algorithm.auxiliary.functions.pfr_fields `pfr_fields`]]
[def __result_of_pfr_fields__ [link fusion.algorithm.auxiliary.metafunctions.pfr_fields `result_of::pfr_fields`]]
[def __fold__ [link fusion.algorithm.iteration.functions.fold `fold`]]
[def __result_of_fold__ [link fusion.algorithm.iteration.metafunctions.fold `result_of::fold`]]
[def __reverse_fold__ [link fusion.algorithm.iteration.functions.reverse_fold `reverse_fold`]]
Expand Down
1 change: 1 addition & 0 deletions doc/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<dt><span class="section"><a href="fusion/view/transform_view.html">transform_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/reverse_view.html">reverse_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/identity_view.html">identity_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/pfr_fields_view.html">pfr_fields_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/nview.html">nview</a></span></dt>
<dt><span class="section"><a href="fusion/view/repetitive_view.html">repetitive_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/flatten_view.html">flatten_view</a></span></dt>
Expand Down
1 change: 1 addition & 0 deletions doc/organization.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ link against.
* transform_view
* zip_view
* identity_view
* pfr_fields_view
* container
* deque
* list
Expand Down
3 changes: 3 additions & 0 deletions doc/sequence.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ For any Forward Sequence s the following invariants always hold:
* __reverse_view__
* __zip_view__
* __identity_view__
* __pfr_fields_view__

[endsect]

Expand Down Expand Up @@ -203,6 +204,7 @@ are not defined in __forward_sequence__.
* __transform_view__ (where adapted sequence is a Bidirectional Sequence)
* __zip_view__ (where adapted sequences are models of Bidirectional Sequence)
* __identity_view__ (where adapted sequence is a Bidirectional Sequence)
* __pfr_fields_view__

[endsect]

Expand Down Expand Up @@ -292,6 +294,7 @@ are not defined in __bidirectional_sequence__.
* __transform_view__ (where adapted sequence is a Random Access Sequence)
* __zip_view__ (where adapted sequences are models of Random Access Sequence)
* __identity_view__ (where adapted sequence is a Random Access Sequence)
* __pfr_fields_view__

[endsect]

Expand Down
92 changes: 92 additions & 0 deletions doc/view.qbk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,96 @@ defined in the implemented models.

[endsect]

[section pfr_fields_view]

[caution This view requires at least C++14! Pre C++14 compilers (C++11, C++03...) are not supported.]

[heading Description]

`pfr_fields_view` is a view into an user defined structure as a random access sequence.
This view does not require macro or boilerplate code from an user defined structure
, unlike __adapt_struct__, and can be used as a replacement for __adapt_struct__.

[heading Header]

#include <boost/fusion/view/pfr_fields_view.hpp>
#include <boost/fusion/include/pfr_fields_view.hpp>

[note This view won't be defined by inclusion of 'boost/fusion/view.hpp'. ]

[heading Synopsis]

template <typename Aggregate>
struct pfr_fields_view;

[heading Template parameters]

[table
[[Parameter] [Description] [Default]]
[[`Aggregate`] [An user defined structure, satisfying __simple_aggregate__ concept] []]
]

[heading Model of]

* __random_access_sequence__

[variablelist Notation
[[`P`] [A `pfr_fields_view` type]]
[[`p`, `p2`] [Instances of `pfr_fields_view`]]
[[`a`] [An instance of __simple_aggregate__]]
]

[heading Expression Semantics]

Semantics of an expression is defined only where it differs from, or is not
defined in __random_access_sequence__.

[table
[[Expression] [Semantics]]
[[`P(a)`] [Creates a `pfr_fields_view` from `a`.]]
[[`P(p)`] [Copy constructs a `pfr_fields_view` from another `pfr_fields_view`, `p`.]]
[[`p = p2`] [Assigns to a `pfr_fields_view`, `p`, from another `pfr_fields_view`, `p2`.]]
]

[heading Example]

struct some_person { // SimpleAggregate
std::string name;
unsigned birth_year = 0;
};

some_person val{"Edgar Allan Poe", 1809};
__pfr_fields_view__<some_person> view(val);
std::cout << view << std::endl; // (Edgar Allan Poe 1809)

[heading Example]

struct empty { // SimpleAggregate
};

struct aggregate : empty { // not a SimpleAggregate because of inheritance
std::string name;
int age = 0;
boost::uuids::uuid uuid;
};

aggregate val{"Edgar Allan Poe", 1809, {}};
__pfr_fields_view__<aggregate> view(val); // non-portable behavior

[heading Example]

using some_person = __vector__< // not a SimpleAggregate
std::string
, unsigned
>;

some_person val("Edgar Allan Poe", 1809);
__pfr_fields_view__<some_person> view(val); // won't compile

[heading See also]

__boost_pfr__

[endsect]

[endsect]
8 changes: 8 additions & 0 deletions include/boost/fusion/algorithm/auxiliary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
#include <boost/fusion/algorithm/auxiliary/move.hpp>
#endif

// Unfortunately, there is no way to determine the compatibility of the pfr library with the current compiler.
// The "boost/fusion/algorithm/auxiliary/pfr_fields.hpp" include has been commented out to ensure backward compatibility
// Please include it manually in your project

// #if !defined(BOOST_FUSION_NO_PFR)
// #include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
// #endif

#endif
Loading