mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
Add static test to detect ability to integrate PFR as fallback into the Fusion
This commit is contained in:
2
test/Jamfile.v2
Normal file → Executable file
2
test/Jamfile.v2
Normal file → Executable file
@@ -53,6 +53,8 @@ test-suite pfr_tests
|
||||
|
||||
[ run offset_based_getter.cpp ]
|
||||
|
||||
[ run can_be_as_fallback_in_the_fusion.cpp ]
|
||||
|
||||
[ 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 ]
|
||||
|
||||
33
test/can_be_as_fallback_in_the_fusion.cpp
Executable file
33
test/can_be_as_fallback_in_the_fusion.cpp
Executable file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2022 Denis Mikhailov
|
||||
//
|
||||
// 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 <type_traits>
|
||||
#include <boost/pfr/traits.hpp>
|
||||
|
||||
struct Aggregate {};
|
||||
using NonAggregate = int;
|
||||
|
||||
namespace boost { namespace pfr {
|
||||
struct boost_fusion_tag;
|
||||
}}
|
||||
|
||||
template<class T, class E=void>
|
||||
struct tag_of_fallback : std::false_type {
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct tag_of_fallback<T, std::enable_if_t<std::is_same<T,T>::value>>
|
||||
{
|
||||
using type = std::conditional_t<
|
||||
boost::pfr::is_implicitly_reflectable<T, boost::pfr::boost_fusion_tag>::value
|
||||
, std::true_type
|
||||
, std::false_type
|
||||
>;
|
||||
};
|
||||
|
||||
static_assert(tag_of_fallback<Aggregate>::type{} == true, "");
|
||||
static_assert(tag_of_fallback<NonAggregate>::type{} == false, "");
|
||||
|
||||
int main() { }
|
||||
Reference in New Issue
Block a user