2
0
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:
Denis Mikhaylov
2022-12-01 14:09:37 +06:00
parent 7a3a419c35
commit ba40d86097
2 changed files with 35 additions and 0 deletions

2
test/Jamfile.v2 Normal file → Executable file
View 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 ]

View 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() { }