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

clenups in tests

This commit is contained in:
Antony Polukhin
2020-10-09 20:44:07 +03:00
parent fa119761f6
commit 0acdbfc7a5
39 changed files with 147 additions and 254 deletions

View File

@@ -508,7 +508,7 @@ constexpr auto internal_tuple_with_same_alignment() noexcept {
static_assert(
std::is_trivial<type>::value && std::is_standard_layout<type>::value,
"====================> Boost.PFR: Type can not be used is flat_ functions, because it's not POD"
"====================> Boost.PFR: Type can not be reflected without Loophole or C++17, because it's not POD"
);
static_assert(!std::is_reference<type>::value, "====================> Boost.PFR: Not applyable");
constexpr auto res = detail::as_flat_tuple_impl<type>(
@@ -528,7 +528,7 @@ struct ubiq_is_flat_refelectable {
template <class Type>
constexpr operator Type() const noexcept {
is_flat_refelectable = std::is_fundamental<Type>::value;
is_flat_refelectable = std::is_fundamental<std::remove_pointer_t<Type>>::value;
return {};
}
};
@@ -562,8 +562,6 @@ auto tie_as_flat_tuple(T& lvalue) noexcept {
return boost::pfr::detail::make_flat_tuple_of_references(lvalue, getter, size_t_<0>{}, size_t_<tuple_type::size_v>{});
}
#if !BOOST_PFR_USE_CPP17
template <class T>
auto tie_as_tuple(T& val) noexcept {
static_assert(
@@ -577,8 +575,6 @@ auto tie_as_tuple(T& val) noexcept {
return boost::pfr::detail::tie_as_flat_tuple(val);
}
#endif // #if !BOOST_PFR_USE_CPP17
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// Structure that can be converted to copy of anything
@@ -597,8 +593,6 @@ struct ubiq_constructor_constexpr_copy {
/////////////////////
#if !BOOST_PFR_USE_CPP17
template <class T, std::size_t... I>
struct is_constexpr_aggregate_initializable { // TODO: try to fix it
template <T = T{ ubiq_constructor_constexpr_copy{I}... } >
@@ -697,8 +691,6 @@ void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
);
}
#endif // #if !BOOST_PFR_USE_CPP17
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -164,81 +164,6 @@ auto tie_as_tuple_loophole_impl(T& lvalue) noexcept {
);
}
// Forward declarations:
template <class T> auto tie_as_tuple_recursively(rvalue_t<T> val) noexcept;
template <class T>
auto tie_or_value(T& val, std::enable_if_t<std::is_class< std::remove_reference_t<T> >::value>* = 0) noexcept {
return boost::pfr::detail::tie_as_tuple_recursively(
boost::pfr::detail::tie_as_tuple_loophole_impl(val)
);
}
template <class T>
decltype(auto) tie_or_value(T& val, std::enable_if_t<std::is_enum<std::remove_reference_t<T>>::value>* = 0) noexcept {
// This is compatible with the pre-loophole implementation, and tests, but IIUC it violates strict aliasing unfortunately
return detail::cast_to_layout_compatible<
std::underlying_type_t<std::remove_reference_t<T> >
>(val);
#if 0
// This "works", in that it's usable and it doesn't violate strict aliasing.
// But it means we break compatibility and don't convert enum to underlying type.
return val;
#endif
}
template <class T>
auto tie_or_value(T& /*val*/, std::enable_if_t<std::is_union< std::remove_reference_t<T> >::value>* = 0) noexcept {
static_assert(
sizeof(T) && false,
"====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
);
return 0;
}
template <class T>
decltype(auto) tie_or_value(T& val, std::enable_if_t<!std::is_class< std::remove_reference_t<T> >::value && !std::is_enum< std::remove_reference_t<T> >::value && !std::is_union< std::remove_reference_t<T> >::value>* = 0) noexcept {
return val;
}
template <class T, std::size_t... I>
auto tie_as_tuple_recursively_impl(T& tup, std::index_sequence<I...> ) noexcept
-> sequence_tuple::tuple<
decltype(boost::pfr::detail::tie_or_value(
sequence_tuple::get<I>(tup)
))...
>
{
return {
boost::pfr::detail::tie_or_value(
sequence_tuple::get<I>(tup)
)...
};
}
template <class T>
auto tie_as_tuple_recursively(rvalue_t<T> tup) noexcept {
using indexes = detail::make_index_sequence<T::size_v>;
return boost::pfr::detail::tie_as_tuple_recursively_impl(tup, indexes{});
}
template <class T>
auto tie_as_flat_tuple(T& t) {
static_assert(
!std::is_union<T>::value,
"====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
);
auto rec_tuples = boost::pfr::detail::tie_as_tuple_recursively(
boost::pfr::detail::tie_as_tuple_loophole_impl(t)
);
return boost::pfr::detail::make_flat_tuple_of_references(
rec_tuples, sequence_tuple_getter{}, size_t_<0>{}, size_t_<decltype(rec_tuples)::size_v>{}
);
}
#if !BOOST_PFR_USE_CPP17
template <class T>
auto tie_as_tuple(T& val) noexcept {
static_assert(
@@ -261,8 +186,6 @@ void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
);
}
#endif // #if !BOOST_PFR_USE_CPP17
}}} // namespace boost::pfr::detail

View File

@@ -19,121 +19,73 @@ project
local DISABLE_ON_MSVC = <toolset>msvc:<build>no ;
local DISABLE_ON_CLANG8_PLUS = <toolset>clang-8:<build>no <toolset>clang-9:<build>no <toolset>clang-10:<build>no ;
local LOOPHOLE_PREC_DEF = <define>BOOST_PFR_USE_LOOPHOLE=1 $(DISABLE_ON_MSVC) $(DISABLE_ON_CLANG8_PLUS) ;
local CLASSIC_PREC_DEF = <define>BOOST_PFR_USE_LOOPHOLE=0 ;
test-suite pfr
local STRUCTURED_BINDING_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=1 [ requires cxx17_structured_bindings ] ;
local LOOPHOLE_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=1 <define>BOOST_PFR_USE_CPP17=0 $(DISABLE_ON_MSVC) $(DISABLE_ON_CLANG8_PLUS) ;
local CLASSIC_ENGINE = <define>BOOST_PFR_USE_LOOPHOLE=0 <define>BOOST_PFR_USE_CPP17=0 ;
test-suite pfr_tests
:
[ run offset_based_getter.cpp ]
[ run ops.cpp : : : $(CLASSIC_PREC_DEF) : ops ]
[ run ops.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_ops ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=char : test_tuple_sizes_on_chars ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=int : test_tuple_sizes_on_ints ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=short : test_tuple_sizes_on_shorts ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON=void* : test_tuple_sizes_on_voidptrs ]
[ run test_tuple_sizes_on.cpp : : : <define>BOOST_PFR_RUN_TEST_ON="std::size_t" : test_tuple_sizes_on_size_ts ]
[ run functions_for.cpp : : : $(CLASSIC_PREC_DEF) : function_for ]
[ run functions_for.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_function_for ]
[ run read_write.cpp : : : $(CLASSIC_PREC_DEF) : read_write ]
[ run read_write.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_read_write ]
[ run std_interactions.cpp : : : $(CLASSIC_PREC_DEF) : std_interactions ]
[ run std_interactions.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_std_interactions ]
[ compile-fail pfr_review_test2.cpp : $(CLASSIC_PREC_DEF) : pfr_review_test2 ]
[ compile-fail pfr_review_test2.cpp : $(LOOPHOLE_PREC_DEF) : lh_pfr_review_test2 ]
[ compile-fail movable_and_lvalue_references.cpp : $(CLASSIC_PREC_DEF) : movable_and_lvalue_references ]
[ compile-fail movable_and_lvalue_references.cpp : $(LOOPHOLE_PREC_DEF) : lh_movable_and_lvalue_references ]
[ compile-fail private_fields.cpp : $(CLASSIC_PREC_DEF) : private_fields ]
[ compile-fail private_fields.cpp : $(LOOPHOLE_PREC_DEF) : lh_private_fields ]
[ compile-fail protected_fields.cpp : $(CLASSIC_PREC_DEF) : protected_fields ]
[ compile-fail protected_fields.cpp : $(LOOPHOLE_PREC_DEF) : lh_protected_fields ]
[ compile-fail virtual_functions.cpp : $(CLASSIC_PREC_DEF) : virtual_functions ]
[ compile-fail virtual_functions.cpp : $(LOOPHOLE_PREC_DEF) : lh_virtual_functions ]
[ compile-fail ops_on_union.cpp : $(CLASSIC_PREC_DEF) : on_union ]
[ compile-fail ops_on_union.cpp : $(LOOPHOLE_PREC_DEF) : lh_on_union ]
[ compile-fail ops_unions.cpp : $(CLASSIC_PREC_DEF) : unions ]
[ compile-fail ops_unions.cpp : $(LOOPHOLE_PREC_DEF) : lh_unions ]
[ compile-fail ops_unrestricted_unions.cpp : $(CLASSIC_PREC_DEF) : unrestricted_unions ]
[ compile-fail ops_unrestricted_unions.cpp : $(LOOPHOLE_PREC_DEF) : lh_unrestricted_unions ]
[ compile-fail rvalue_tie.cpp : $(CLASSIC_PREC_DEF) : rvalue_tie ]
[ compile-fail rvalue_tie.cpp : $(LOOPHOLE_PREC_DEF) : lh_rvalue_tie ]
[ run non_std_layout.cpp : : : $(CLASSIC_PREC_DEF) : non_standard_layout ]
[ run non_std_layout.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_non_standard_layout ]
[ run non_default_constructible.cpp : : : $(CLASSIC_PREC_DEF) : non_default_constructible ]
[ run non_default_constructible.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_non_default_constructible ]
[ run non_copyable_but_movable.cpp : : : $(CLASSIC_PREC_DEF) : non_copyable_but_movable ]
[ run non_copyable_but_movable.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_non_copyable_but_movable ]
[ run non_default_constructible_non_copyable_but_movable.cpp : : : $(CLASSIC_PREC_DEF) : non_dc_non_cop_but_mov ]
[ run non_default_constructible_non_copyable_but_movable.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_non_dc_non_cop_but_mov ]
[ compile-fail fields_count_on_reference.cpp ]
[ run fields_count_on_const.cpp ]
[ run test_tuple_sizes_on.cpp : : : $(DISABLE_ON_MSVC) <define>BOOST_PFR_RUN_TEST_ON=char : test_tuple_sizes_on_chars ]
[ run test_tuple_sizes_on.cpp : : : $(DISABLE_ON_MSVC) <define>BOOST_PFR_RUN_TEST_ON=int : test_tuple_sizes_on_ints ]
[ run test_tuple_sizes_on.cpp : : : $(DISABLE_ON_MSVC) <define>BOOST_PFR_RUN_TEST_ON=short : test_tuple_sizes_on_shorts ]
[ run test_tuple_sizes_on.cpp : : : $(DISABLE_ON_MSVC) <define>BOOST_PFR_RUN_TEST_ON=void* : test_tuple_sizes_on_voidptrs ]
[ run test_tuple_sizes_on.cpp : : : $(DISABLE_ON_MSVC) <define>BOOST_PFR_RUN_TEST_ON="std::size_t" : test_tuple_sizes_on_size_ts ]
[ run tuple_size.cpp : : : $(CLASSIC_PREC_DEF) : tuple_size ]
[ run bitfields.cpp : : : $(CLASSIC_PREC_DEF) : tuple_size_on_bitfields ]
[ run for_each_field.cpp : : : $(CLASSIC_PREC_DEF) : for_each_field ]
[ run motivating_example0.cpp : : : $(CLASSIC_PREC_DEF) : motivating_example0 ]
[ run motivating_example.cpp : : : $(CLASSIC_PREC_DEF) : motivating_example ]
[ run motivating_example2.cpp : : : $(CLASSIC_PREC_DEF) : motivating_example2 ]
[ run optional_like.cpp : : : $(CLASSIC_PREC_DEF) : optional_like ]
[ run get_non_default_constructible.cpp : : : $(CLASSIC_PREC_DEF) : get_non_default_constructible ]
[ run destructuring_tie.cpp : : : $(CLASSIC_PREC_DEF) : destructuring_tie ]
[ run error_pfr_c1202.cpp : : : $(CLASSIC_PREC_DEF) : c1202_issue21 ]
[ compile-fail non_aggregate.cpp : $(CLASSIC_PREC_DEF) : non_aggregate ]
[ run tie_anonymous.cpp : : : $(CLASSIC_PREC_DEF) [ requires cxx17_structured_bindings ] : tie_anonymous ]
# See "Requirements and Limitations" section of the docs for info on following tests:
#[ compile-fail template_constructor.cpp : $(CLASSIC_PREC_DEF) [ requires !cxx17_structured_bindings ] : template_constructor14 ]
#[ compile-fail template_unconstrained.cpp : $(CLASSIC_PREC_DEF) [ requires !cxx17_structured_bindings ] : template_unconstrained14 ]
[ run template_constructor.cpp : : : $(CLASSIC_PREC_DEF) [ requires cxx17_structured_bindings ] : template_constructor ]
# TODO:
#[ run template_unconstrained.cpp : : : $(CLASSIC_PREC_DEF) [ requires cxx17_structured_bindings ] : template_unconstrained ]
# The following tests may compile of fail depending on C++ Standard version.
#[ compile-fail issue30.cpp : $(CLASSIC_PREC_DEF) : issue30 ]
#[ compile-fail issue33.cpp : $(CLASSIC_PREC_DEF) : issue33 ]
[ run tuple_size.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_tuple_size ]
[ run bitfields.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_tuple_size_on_bitfields ]
[ run for_each_field.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_for_each_field ]
[ run motivating_example0.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_motivating_example0 ]
[ run motivating_example.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_motivating_example ]
[ run motivating_example2.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_motivating_example2 ]
[ run optional_like.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_optional_like ]
[ run get_non_default_constructible.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_get_non_default_constructible ]
[ run error_pfr_c1202.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_c1202_issue21 ]
[ run issue30.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_issue30 ]
[ run issue33.cpp : : : $(LOOPHOLE_PREC_DEF) : lh_issue33 ]
[ compile-fail non_aggregate.cpp : $(LOOPHOLE_PREC_DEF) : lh_non_aggregate ]
[ run tie_anonymous.cpp : : : $(LOOPHOLE_PREC_DEF) [ requires cxx17_structured_bindings ] : lh_tie_anonymous ]
# See "Requirements and Limitations" section of the docs for info on following tests:
#[ compile-fail template_constructor.cpp : $(LOOPHOLE_PREC_DEF) [ requires !cxx17_structured_bindings ] : lh_template_constructor14 ]
#[ compile-fail template_unconstrained.cpp : $(LOOPHOLE_PREC_DEF) [ requires !cxx17_structured_bindings ] : lh_template_unconstrained14 ]
[ run template_constructor.cpp : : : $(LOOPHOLE_PREC_DEF) [ requires cxx17_structured_bindings ] : lh_template_constructor ]
# TODO:
#[ run template_unconstrained.cpp : : : $(LOOPHOLE_PREC_DEF) [ requires cxx17_structured_bindings ] : lh_template_unconstrained ]
# Examples from docs
[ run ../example/quick_examples.cpp : : : $(DISABLE_ON_MSVC) ]
[ run run/motivating_example.cpp : : : : auto_engine_detection ]
# TODO: template_unconstrained.cpp does not work at all
#[ run template_unconstrained.cpp : : : $(STRUCTURED_BINDING_ENGINE) : template_unconstrained_sb ]
#[ run template_unconstrained.cpp : : : $(LOOPHOLE_ENGINE) : template_unconstrained_lh ]
#[ compile-fail template_unconstrained.cpp : $(CLASSIC_ENGINE) : template_unconstrained_classic ]
;
local BLACKLIST_TESTS_FOR_LOOPHOLE =
template_constructor # Template constructor in one of the fields of the aggregate
tie_anonymous # TODO: const is dropped, fix
;
# Those tests are either
# * reflecting a non literal type
# * or calling boost::pfr::get and the result is a user defined structure
local BLACKLIST_TESTS_FOR_CLASSIC =
get_non_default_constructible
issue30
issue33
motivating_example0
motivating_example2
optional_like
read_write_non_literal
template_constructor
tie_anonymous
;
for local source_file in [ glob ./run/*.cpp ] ../example/quick_examples.cpp
{
local target_name = $(source_file[1]:B) ;
pfr_tests += [ run $(source_file) : : : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
if ! $(target_name) in $(BLACKLIST_TESTS_FOR_LOOPHOLE)
{
pfr_tests += [ run $(source_file) : : : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
}
if ! $(target_name) in $(BLACKLIST_TESTS_FOR_CLASSIC)
{
pfr_tests += [ run $(source_file) : : : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
else
{
pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
}
for local source_file in [ glob ./compile-fail/*.cpp ]
{
local target_name = $(source_file[1]:B) ;
pfr_tests += [ compile-fail $(source_file) : $(STRUCTURED_BINDING_ENGINE) : $(target_name)_sb ] ;
pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}

View File

@@ -3,8 +3,7 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/pfr/core.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/pfr/tuple_size.hpp>
struct bf {
unsigned int i1: 1;
@@ -16,8 +15,7 @@ struct bf {
};
int main() {
(void)boost::pfr::tuple_size<bf>::value;
return boost::report_errors();
static_assert(boost::pfr::tuple_size<bf>::value == 6, "");
}

View File

@@ -7,8 +7,6 @@
#include <boost/pfr/core.hpp>
#include <boost/core/lightweight_test.hpp>
#if BOOST_PFR_USE_CPP17 || BOOST_PFR_USE_LOOPHOLE
auto parseHex(char const* p, size_t limit = ~0u) {
struct { size_t val; char const* rest; } res = { 0, p };
while (limit) {
@@ -60,12 +58,3 @@ int main() {
return boost::report_errors();
}
#else // C++14 without loophole
#include <iostream>
int main(int, char** argv) {
std::cerr << argv[0] << ": Not supported in C++14 without reflection loophole.\n";
}
#endif

View File

@@ -19,11 +19,9 @@ struct Foo {
};
int main() {
#if BOOST_PFR_USE_LOOPHOLE || BOOST_PFR_USE_CPP17
Foo f{0};
f.a.val_ = 5;
BOOST_TEST_EQ(boost::pfr::get<0>(f).val_, 5);
return boost::report_errors();
#endif
}

View File

@@ -13,10 +13,8 @@ struct some_person {
};
int main() {
#if BOOST_PFR_USE_LOOPHOLE || BOOST_PFR_USE_CPP17
some_person val{"Edgar Allan Poe", 1809};
std::cout << boost::pfr::get<0>(val)
<< " was born in " << boost::pfr::get<1>(val);
#endif
}

View File

@@ -12,11 +12,9 @@ struct my_struct { // no ostream operator defined!
};
int main() {
#if BOOST_PFR_USE_CPP17 || BOOST_PFR_USE_LOOPHOLE
using namespace boost::pfr::ops; // C++17 out-of-the-box ostream operators for aggregate initializables!
my_struct s{{"Das ist fantastisch!"}, 100};
std::cout << "my_struct has " << boost::pfr::tuple_size<my_struct>::value
<< " fields: " << s << "\n";
#endif
}

View File

@@ -19,11 +19,9 @@ struct Foo {
};
int main() {
#if BOOST_PFR_USE_LOOPHOLE || BOOST_PFR_USE_CPP17
Foo f{0};
f.a.val_ = 5;
BOOST_TEST_EQ(boost::pfr::get<0>(f).val_, 5);
return boost::report_errors();
#endif
}

View File

@@ -90,38 +90,6 @@ int main() {
"{1, 2, 3, 4, {with_operator}}"
);
#if (BOOST_PFR_USE_CPP17 || BOOST_PFR_USE_LOOPHOLE) \
&& !defined(_MSC_VER) /* TODO: remove after fixing strange errors https://ci.appveyor.com/project/apolukhin/magic-get/build/1.65.108-develop */
struct test4 {
int f0;
std::string f1;
char f2;
int f3;
std::string f4;
};
test_type(
test4{1, {"my o my"}, '3', 4, {"hello there!"} },
"{1, \"my o my\", 3, 4, \"hello there!\"}"
);
#if 0
// TODO:
std::string f1_referenced{"my O my"};
std::string f4_referenced{"Hello There!"};
struct test5 {
int f0;
const std::string& f1;
char f2;
int f3;
const std::string& f4;
};
to_string_test(
test5{1, f1_referenced, '3', 4, f4_referenced },
"{1, \"my o my\", 3, 4, \"hello there!\"}"
);
#endif
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,75 @@
// Copyright (c) 2016-2020 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/pfr/io.hpp>
#include <sstream>
#include <string>
#include <boost/core/lightweight_test.hpp>
template <class T>
void test_write_read(const T& value) {
T result;
std::stringstream ss;
boost::pfr::write(ss, value);
boost::pfr::read(ss, result);
BOOST_TEST_EQ(value.f0, result.f0);
BOOST_TEST_EQ(value.f1, result.f1);
BOOST_TEST_EQ(value.f2, result.f2);
BOOST_TEST_EQ(value.f3, result.f3);
BOOST_TEST_EQ(value.f4, result.f4);
}
template <class T>
void to_string_test(const T& value, const char* ethalon) {
std::stringstream ss;
boost::pfr::write(ss, value);
BOOST_TEST_EQ(ss.str(), ethalon);
}
template <class T>
void test_type(const T& value, const char* ethalon) {
test_write_read(value);
to_string_test(value, ethalon);
}
int main() {
#if !defined(_MSC_VER) /* TODO: remove after fixing strange errors https://ci.appveyor.com/project/apolukhin/magic-get/build/1.65.108-develop */
struct test4 {
int f0;
std::string f1;
char f2;
int f3;
std::string f4;
};
test_type(
test4{1, {"my o my"}, '3', 4, {"hello there!"} },
"{1, \"my o my\", 3, 4, \"hello there!\"}"
);
#if 0
// TODO:
std::string f1_referenced{"my O my"};
std::string f4_referenced{"Hello There!"};
struct test5 {
int f0;
const std::string& f1;
char f2;
int f3;
const std::string& f4;
};
to_string_test(
test5{1, f1_referenced, '3', 4, f4_referenced },
"{1, \"my o my\", 3, 4, \"hello there!\"}"
);
#endif
#endif
return boost::report_errors();
}

View File

@@ -8,6 +8,7 @@
#include <boost/pfr/ops.hpp>
#include <string>
#include <type_traits>
#if defined(__has_include)
# if __has_include(<optional>)
@@ -57,8 +58,9 @@ void test_in_anon_ns() {
auto v = boost::pfr::structure_tie(x);
BOOST_TEST_EQ(std::get<0>(v).data, 1);
BOOST_TEST_EQ(std::get<1>(v).data, 2);
using v_type = decltype(v);
static_assert(std::is_same<
std::tuple<other_anon&, const other_anon&>, decltype(v)
std::tuple<other_anon&, const other_anon&>, v_type
>::value, "");
auto const_v = boost::pfr::structure_tie(const_x);
@@ -84,8 +86,9 @@ void test_in_non_non_ns() {
auto v = boost::pfr::structure_tie(x);
BOOST_TEST_EQ(std::get<0>(v).data, 1);
BOOST_TEST_EQ(std::get<1>(v).data, 2);
using v_type = decltype(v);
static_assert(std::is_same<
std::tuple<other_anon&, const other_anon&>, decltype(v)
std::tuple<other_anon&, const other_anon&>, v_type
>::value, "");
auto const_v = boost::pfr::structure_tie(const_x);

View File

@@ -30,6 +30,7 @@ struct int_element {
int value_;
};
struct aggregate_unconstrained {
unconstrained_template<int> a;
unconstrained_template<int_element> b;