Skip to content

Commit aed0503

Browse files
committed
[pfr_implicit_explicit] Force pfr implicit reflection in cxx14 mode
1 parent cd54084 commit aed0503

4 files changed

Lines changed: 42 additions & 20 deletions

File tree

test/Jamfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ project
7070

7171
[ compile include/adapted.cpp ]
7272
[ compile include/_boost_pfr.cpp
73-
: [ requires cxx17_structured_bindings ] ]
73+
: <define>BOOST_PFR_ENABLE_IMPLICIT_REFLECTION=1 [ requires cxx14_constexpr ] ]
7474
[ compile include/_boost_pfr_explicit.cpp
7575
: [ requires cxx14_constexpr ] ]
7676

@@ -81,11 +81,11 @@ project
8181
[ run sequence/as_set.cpp ]
8282
[ run sequence/as_vector.cpp ]
8383
[ run sequence/boost_pfr.cpp : :
84-
: [ requires cxx17_structured_bindings ] ]
84+
: <define>BOOST_PFR_ENABLE_IMPLICIT_REFLECTION=1 [ requires cxx14_constexpr ] ]
8585
[ run sequence/boost_pfr_empty.cpp : :
86-
: [ requires cxx17_structured_bindings ] ]
86+
: <define>BOOST_PFR_ENABLE_IMPLICIT_REFLECTION=1 [ requires cxx14_constexpr ] ]
8787
[ run sequence/boost_pfr_convert.cpp : :
88-
: [ requires cxx17_structured_bindings ] ]
88+
: <define>BOOST_PFR_ENABLE_IMPLICIT_REFLECTION=1 [ requires cxx14_constexpr ] ]
8989
[ run sequence/boost_pfr_iterator.cpp : :
9090
: [ requires cxx14_constexpr ] ]
9191
[ run sequence/boost_pfr_force_macro.cpp : :

test/sequence/boost_pfr.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,36 @@ namespace ns {
5252
}
5353

5454
// Testing non-constexpr compatible types
55+
#if BOOST_PFR_USE_CPP17 != 0
5556
struct employee {
5657
guaranteed_nonconstexpr_string name;
5758
guaranteed_nonconstexpr_string nickname;
5859
};
60+
#endif // BOOST_PFR_USE_CPP17
5961
}
6062

6163
struct s { int m; };
6264

6365
int
6466
main()
6567
{
66-
using namespace boost::fusion;
67-
using namespace boost;
68+
using boost::fusion::tuple_open;
69+
using boost::fusion::tuple_close;
70+
using boost::fusion::tuple_delimiter;
71+
using boost::fusion::at_c;
72+
using boost::fusion::make_vector;
73+
using boost::fusion::front;
74+
using boost::fusion::back;
75+
using boost::fusion::vector;
76+
using boost::fusion::list;
77+
namespace traits = boost::fusion::traits;
78+
namespace fusion = boost::fusion;
6879
using ns::point;
6980

70-
std::cout << tuple_open('[');
71-
std::cout << tuple_close(']');
72-
std::cout << tuple_delimiter(", ");
81+
// FIXME make this workable even with forced implicit reflection
82+
// std::cout << tuple_open('[');
83+
// std::cout << tuple_close(']');
84+
// std::cout << tuple_delimiter(", ");
7385

7486
{
7587
static_assert(!traits::is_view< point >::value, "");
@@ -78,7 +90,7 @@ main()
7890
std::cout << at_c<0>(p) << std::endl;
7991
std::cout << at_c<1>(p) << std::endl;
8092
std::cout << at_c<2>(p) << std::endl;
81-
std::cout << p << std::endl;
93+
boost::fusion::out(std::cout, p) << std::endl;
8294
BOOST_TEST(p == make_vector(123, 456, 789));
8395

8496
at_c<0>(p) = 6;
@@ -146,16 +158,18 @@ main()
146158
// , boost::mpl::front<ns::point>::type>::value, "");
147159
}
148160

161+
#if BOOST_PFR_USE_CPP17 != 0
149162
{
150163
ns::employee emp{ns::guaranteed_nonconstexpr_string("John Doe"),
151-
ns::guaranteed_nonconstexpr_string("jdoe")};
164+
ns::guaranteed_nonconstexpr_string("jdoe")};
152165
std::cout << at_c<0>(emp).value << std::endl;
153166
std::cout << at_c<1>(emp).value << std::endl;
154167

155168
fusion::vector<ns::guaranteed_nonconstexpr_string, ns::guaranteed_nonconstexpr_string> v1(
156169
ns::guaranteed_nonconstexpr_string("John Doe"), ns::guaranteed_nonconstexpr_string("jdoe"));
157170
BOOST_TEST(emp == v1);
158171
}
172+
#endif // BOOST_PFR_USE_CPP17
159173

160174
{
161175
int a[3] = {100, 200, 300};

test/sequence/boost_pfr_convert.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <boost/mpl/assert.hpp>
3030
#include <iostream>
3131
#include <string>
32+
#include <cstring>
3233

3334
#include <boost/fusion/include/vector.hpp>
3435
#include <boost/fusion/include/deque.hpp>
@@ -38,15 +39,15 @@
3839

3940
struct SimpleAggregate {
4041
int first;
41-
std::string second;
42+
const char* second;
4243
};
4344

4445
template <typename Tag, typename Seq>
4546
void test(Seq const& seq)
4647
{
4748
const auto v = boost::fusion::convert<Tag>(seq);
4849
BOOST_TEST((boost::fusion::at_c<0>(v) == 123));
49-
BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!"));
50+
BOOST_TEST((std::strcmp(boost::fusion::at_c<1>(v), "Hola!!!") == 0));
5051
}
5152

5253
int

test/sequence/boost_pfr_empty.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,26 @@ struct empty_struct {};
3333
int
3434
main()
3535
{
36-
using namespace boost::fusion;
37-
using namespace boost;
38-
39-
std::cout << tuple_open('[');
40-
std::cout << tuple_close(']');
41-
std::cout << tuple_delimiter(", ");
36+
using boost::fusion::tuple_open;
37+
using boost::fusion::tuple_close;
38+
using boost::fusion::tuple_delimiter;
39+
using boost::fusion::make_vector;
40+
using boost::fusion::vector;
41+
using boost::fusion::list;
42+
namespace traits = boost::fusion::traits;
43+
namespace fusion = boost::fusion;
44+
45+
// FIXME make this workable even with forced implicit reflection
46+
// std::cout << tuple_open('[');
47+
// std::cout << tuple_close(']');
48+
// std::cout << tuple_delimiter(", ");
4249

4350
{
4451
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
4552
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
4653
empty_struct e;
4754

48-
std::cout << e << std::endl;
55+
boost::fusion::out(std::cout, e) << std::endl;
4956
BOOST_TEST(e == make_vector());
5057

5158
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);

0 commit comments

Comments
 (0)