Skip to content

Commit 74dcf5c

Browse files
committed
[pfr_extension] Implemented macro adapter
1 parent c243f8b commit 74dcf5c

20 files changed

Lines changed: 923 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/adapted.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@
2323
#include <boost/fusion/adapted/std_tuple.hpp>
2424
#endif
2525

26+
// Unfortunately, there is no way to determine the compatibility of the pfr library with the current compiler.
27+
// The "boost/fusion/adapted/pfr.hpp" include has been commented out to ensure backward compatibility
28+
// Please include it manually in your project
29+
30+
// #if !defined(BOOST_FUSION_NO_PFR)
31+
// #include <boost/fusion/adapted/pfr.hpp>
32+
// #endif
33+
2634
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
#ifndef BOOST_FUSION_ADAPTED_PFR_HPP
8+
#define BOOST_FUSION_ADAPTED_PFR_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/adapted/pfr/detail/at_impl.hpp>
12+
#include <boost/fusion/adapted/pfr/detail/begin_impl.hpp>
13+
#include <boost/fusion/adapted/pfr/detail/category_of_impl.hpp>
14+
#include <boost/fusion/adapted/pfr/detail/end_impl.hpp>
15+
#include <boost/fusion/adapted/pfr/detail/is_sequence_impl.hpp>
16+
#include <boost/fusion/adapted/pfr/detail/is_view_impl.hpp>
17+
#include <boost/fusion/adapted/pfr/detail/size_impl.hpp>
18+
#include <boost/fusion/adapted/pfr/detail/value_at_impl.hpp>
19+
#include <boost/fusion/adapted/pfr/adapt_pfr.hpp>
20+
21+
#endif
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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_ADAPTED_STRUCT_ADAPT_PFR_HPP)
8+
#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_PFR_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/adapted/pfr/detail/at_impl.hpp>
12+
#include <boost/fusion/adapted/pfr/detail/begin_impl.hpp>
13+
#include <boost/fusion/adapted/pfr/detail/category_of_impl.hpp>
14+
#include <boost/fusion/adapted/pfr/detail/end_impl.hpp>
15+
#include <boost/fusion/adapted/pfr/detail/is_sequence_impl.hpp>
16+
#include <boost/fusion/adapted/pfr/detail/is_view_impl.hpp>
17+
#include <boost/fusion/adapted/pfr/detail/size_impl.hpp>
18+
#include <boost/fusion/adapted/pfr/detail/value_at_impl.hpp>
19+
#include <boost/fusion/support/tag_of_fwd.hpp>
20+
21+
#define BOOST_FUSION_ADAPT_PFR(NAME) \
22+
\
23+
namespace boost { namespace fusion { \
24+
struct pfr_tag; \
25+
struct fusion_sequence_tag; \
26+
\
27+
namespace traits \
28+
{ \
29+
template<> \
30+
struct tag_of<NAME> \
31+
{ \
32+
using type = pfr_tag; \
33+
}; \
34+
template<> \
35+
struct tag_of<NAME const> \
36+
{ \
37+
using type = pfr_tag; \
38+
}; \
39+
} \
40+
}} \
41+
\
42+
namespace boost { namespace mpl \
43+
{ \
44+
template<typename> \
45+
struct sequence_tag; \
46+
\
47+
template<> \
48+
struct sequence_tag<NAME> \
49+
{ \
50+
using type = fusion::fusion_sequence_tag; \
51+
}; \
52+
\
53+
template<> \
54+
struct sequence_tag<NAME const> \
55+
{ \
56+
using type = fusion::fusion_sequence_tag; \
57+
}; \
58+
}}
59+
60+
#define BOOST_FUSION_ADAPT_TPL_PFR(NAME) \
61+
\
62+
namespace boost { namespace fusion { \
63+
struct pfr_tag; \
64+
struct fusion_sequence_tag; \
65+
\
66+
namespace traits \
67+
{ \
68+
template<typename... Args> \
69+
struct tag_of<NAME<Args...>> \
70+
{ \
71+
using type = pfr_tag; \
72+
}; \
73+
template<typename... Args> \
74+
struct tag_of<NAME<Args...> const> \
75+
{ \
76+
using type = pfr_tag; \
77+
}; \
78+
} \
79+
}} \
80+
\
81+
namespace boost { namespace mpl \
82+
{ \
83+
template<typename> \
84+
struct sequence_tag; \
85+
\
86+
template<typename... Args> \
87+
struct sequence_tag<NAME<Args...>> \
88+
{ \
89+
using type = fusion::fusion_sequence_tag; \
90+
}; \
91+
\
92+
template<typename... Args> \
93+
struct sequence_tag<NAME<Args...> const> \
94+
{ \
95+
using type = fusion::fusion_sequence_tag; \
96+
}; \
97+
}}
98+
99+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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_ADAPTED_PFR_DETAIL_AT_IMPL_HPP)
8+
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_AT_IMPL_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view.hpp>
12+
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
13+
#include <boost/fusion/sequence/intrinsic/at.hpp>
14+
15+
namespace boost { namespace fusion
16+
{
17+
struct pfr_tag;
18+
19+
namespace extension
20+
{
21+
template<typename T>
22+
struct at_impl;
23+
24+
template<>
25+
struct at_impl<pfr_tag>
26+
{
27+
template <typename Aggregate, typename N>
28+
struct apply
29+
{
30+
using type = typename result_of::at< pfr_fields_view<Aggregate>, N >::type;
31+
32+
constexpr BOOST_FUSION_GPU_ENABLED
33+
static type
34+
call(Aggregate& seq)
35+
{
36+
return at<N>(pfr_fields(seq));
37+
}
38+
};
39+
};
40+
}
41+
}}
42+
43+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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_ADAPTED_PFR_DETAIL_BEGIN_IMPL_HPP)
8+
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_BEGIN_IMPL_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view.hpp>
12+
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
13+
#include <boost/fusion/sequence/intrinsic/begin.hpp>
14+
15+
namespace boost { namespace fusion
16+
{
17+
struct pfr_tag;
18+
19+
namespace extension
20+
{
21+
template<typename T>
22+
struct begin_impl;
23+
24+
template <>
25+
struct begin_impl<pfr_tag>
26+
{
27+
template <typename Aggregate>
28+
struct apply
29+
{
30+
using type = typename result_of::begin< pfr_fields_view<Aggregate> >::type;
31+
32+
constexpr BOOST_FUSION_GPU_ENABLED
33+
static type
34+
call(Aggregate& seq)
35+
{
36+
return begin(pfr_fields(seq));
37+
}
38+
};
39+
};
40+
}
41+
}}
42+
43+
#endif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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_ADAPTED_PFR_DETAIL_CATEGORY_OF_IMPL_HPP)
8+
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_CATEGORY_OF_IMPL_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
12+
namespace boost { namespace fusion
13+
{
14+
struct pfr_tag;
15+
struct random_access_traversal_tag;
16+
17+
namespace extension
18+
{
19+
template<typename T>
20+
struct category_of_impl;
21+
22+
template<>
23+
struct category_of_impl<pfr_tag>
24+
{
25+
template<typename T>
26+
struct apply
27+
{
28+
using type = random_access_traversal_tag;
29+
};
30+
};
31+
}
32+
}}
33+
34+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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_ADAPTED_PFR_DETAIL_END_IMPL_HPP)
8+
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_END_IMPL_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/fusion/view/pfr_fields_view.hpp>
12+
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
13+
#include <boost/fusion/sequence/intrinsic/end.hpp>
14+
15+
namespace boost { namespace fusion
16+
{
17+
struct pfr_tag;
18+
19+
namespace extension
20+
{
21+
template<typename T>
22+
struct end_impl;
23+
24+
template<>
25+
struct end_impl<pfr_tag>
26+
{
27+
template <typename Aggregate>
28+
struct apply
29+
{
30+
using type = typename result_of::end< pfr_fields_view<Aggregate> >::type;
31+
32+
constexpr BOOST_FUSION_GPU_ENABLED
33+
static type
34+
call(Aggregate& seq)
35+
{
36+
return end(pfr_fields(seq));
37+
}
38+
};
39+
};
40+
}
41+
}}
42+
43+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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_ADAPTED_PFR_DETAIL_IS_SEQUENCE_IMPL_HPP)
8+
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_IS_SEQUENCE_IMPL_HPP
9+
10+
#include <boost/fusion/support/config.hpp>
11+
#include <boost/mpl/bool.hpp>
12+
13+
namespace boost { namespace fusion
14+
{
15+
struct pfr_tag;
16+
17+
namespace extension
18+
{
19+
template<typename Tag>
20+
struct is_sequence_impl;
21+
22+
template<>
23+
struct is_sequence_impl<pfr_tag>
24+
{
25+
template<typename Aggregate>
26+
struct apply : mpl::true_ {};
27+
};
28+
}
29+
}}
30+
31+
#endif

0 commit comments

Comments
 (0)