Skip to content

Commit afaa50f

Browse files
committed
[pfr_view] Implemented pfr_fields_view
1 parent 5ba02db commit afaa50f

28 files changed

Lines changed: 1161 additions & 0 deletions

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ target_link_libraries(boost_fusion
2323
Boost::type_traits
2424
Boost::typeof
2525
Boost::utility
26+
Boost::pfr
2627
)

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ install:
8282
- git submodule init libs/type_traits
8383
- git submodule init libs/typeof
8484
- git submodule init libs/utility
85+
- git submodule init libs/pfr
8586

8687
- git submodule init libs/headers tools/boost_install tools/build
8788
- git submodule update

include/boost/fusion/algorithm/auxiliary.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@
1313
#include <boost/fusion/algorithm/auxiliary/move.hpp>
1414
#endif
1515

16+
// Unfortunately, there is no way to determine the compatibility of the pfr library with the current compiler.
17+
// The "boost/fusion/algorithm/auxiliary/pfr_fields.hpp" include has been commented out to ensure backward compatibility
18+
// Please include it manually in your project
19+
20+
// #if !defined(BOOST_FUSION_NO_PFR)
21+
// #include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
22+
// #endif
23+
1624
#endif
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(FUSION_PFR_FIELDS_54763465_8735)
8+
#define FUSION_PFR_FIELDS_54763465_8735
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view/pfr_fields_view.hpp>
12+
13+
namespace boost { namespace fusion { namespace result_of
14+
{
15+
template<typename Aggregate>
16+
struct pfr_fields
17+
{
18+
typedef pfr_fields_view<Aggregate> type;
19+
};
20+
}}}
21+
22+
namespace boost { namespace fusion
23+
{
24+
template <typename Aggregate>
25+
constexpr BOOST_FUSION_GPU_ENABLED
26+
auto pfr_fields(Aggregate& view)
27+
{
28+
using type = typename result_of::pfr_fields<Aggregate>::type;
29+
return type(view);
30+
}
31+
32+
template <typename Aggregate>
33+
constexpr BOOST_FUSION_GPU_ENABLED
34+
auto pfr_fields(Aggregate const& view)
35+
{
36+
using type = typename result_of::pfr_fields<Aggregate const>::type;
37+
return type(view);
38+
}
39+
}}
40+
41+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(FUSION_INCLUDE_PFR_FIELDS)
8+
#define FUSION_INCLUDE_PFR_FIELDS
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
12+
13+
14+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(FUSION_INCLUDE_PFR_FIELDS_VIEW)
8+
#define FUSION_INCLUDE_PFR_FIELDS_VIEW
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view.hpp>
12+
13+
14+
#endif

include/boost/fusion/view.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@
1919
#include <boost/fusion/view/flatten_view.hpp>
2020
#include <boost/fusion/view/identity_view.hpp>
2121

22+
// Unfortunately, there is no way to determine the compatibility of the pfr library with the current compiler.
23+
// The "boost/fusion/view/pfr_fields_view.hpp" include has been commented out to ensure backward compatibility
24+
// Please include it manually in your project
25+
26+
// #if !defined(BOOST_FUSION_NO_PFR)
27+
// #include <boost/fusion/view/pfr_fields_view.hpp>
28+
// #endif
29+
2230
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(BOOST_FUSION_PFR_FIELDS_VIEW_JAN_17_2022_0726PM)
8+
#define BOOST_FUSION_PFR_FIELDS_VIEW_JAN_17_2022_0726PM
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view/pfr_fields_view.hpp>
12+
#include <boost/fusion/view/pfr_fields_view/pfr_fields_view_iterator.hpp>
13+
14+
#endif
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(BOOST_FUSION_PFR_FIELDS_VIEW_ADVANCE_IMPL_HPP_INCLUDED)
8+
#define BOOST_FUSION_PFR_FIELDS_VIEW_ADVANCE_IMPL_HPP_INCLUDED
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/mpl/int.hpp>
12+
13+
namespace boost { namespace fusion {
14+
struct pfr_fields_view_iterator_tag;
15+
16+
template<typename Aggregate, typename Pos>
17+
struct pfr_fields_view_iterator;
18+
19+
namespace extension
20+
{
21+
template<typename Tag>
22+
struct advance_impl;
23+
24+
template<>
25+
struct advance_impl<pfr_fields_view_iterator_tag>
26+
{
27+
template<typename Iterator, typename N>
28+
struct apply
29+
{
30+
using type = pfr_fields_view_iterator<
31+
typename Iterator::aggregate_type
32+
, mpl::int_<Iterator::index::value + N::value>
33+
>;
34+
35+
constexpr BOOST_FUSION_GPU_ENABLED
36+
static auto
37+
call(Iterator const& it)
38+
{
39+
return type(it.agg);
40+
}
41+
};
42+
};
43+
}
44+
}}
45+
46+
#endif
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*=============================================================================
2+
Copyright (c) 2022 Denis Mikhailov
3+
Distributed under the Boost Software License, Version 1.0. (See accompanying
4+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
==============================================================================*/
6+
7+
#if !defined(BOOST_FUSION_PFR_FIELDS_VIEW_AT_IMPL_HPP_INCLUDED)
8+
#define BOOST_FUSION_PFR_FIELDS_VIEW_AT_IMPL_HPP_INCLUDED
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/pfr/core.hpp>
12+
#include <utility> // for std::declval
13+
14+
namespace boost { namespace fusion {
15+
struct pfr_fields_view_tag;
16+
17+
namespace extension
18+
{
19+
template<typename Tag>
20+
struct at_impl;
21+
22+
template <>
23+
struct at_impl<pfr_fields_view_tag>
24+
{
25+
template <typename Sequence, typename N>
26+
struct apply
27+
{
28+
using type = decltype(boost::pfr::get<N::value>(std::declval<Sequence>().agg));
29+
30+
constexpr BOOST_FUSION_GPU_ENABLED
31+
static decltype(auto)
32+
call(Sequence& v)
33+
{
34+
return boost::pfr::get<N::value>(v.agg);
35+
}
36+
};
37+
};
38+
}
39+
}}
40+
41+
#endif

0 commit comments

Comments
 (0)