1// Copyright (c) 2022 Denis Mikhailov
2//
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#ifndef BOOST_PFR_DETAIL_POSSIBLE_REFLECTABLE_HPP
7#define BOOST_PFR_DETAIL_POSSIBLE_REFLECTABLE_HPP
8#pragma once
9
10#include <boost/pfr/detail/config.hpp>
11#include <boost/pfr/traits_fwd.hpp>
12
13#include <type_traits> // for std::is_aggregate
14
15namespace boost { namespace pfr { namespace detail {
16
17///////////////////// Returns false when the type exactly wasn't be reflectable
18template <class T, class WhatFor>
19constexpr decltype(is_reflectable<T, WhatFor>::value) possible_reflectable(long) noexcept {
20 return is_reflectable<T, WhatFor>::value;
21}
22
23#if BOOST_PFR_ENABLE_IMPLICIT_REFLECTION
24
25template <class T, class WhatFor>
26constexpr bool possible_reflectable(int) noexcept {
27# if defined(__cpp_lib_is_aggregate)
28 using type = std::remove_cv_t<T>;
29 return std::is_aggregate<type>();
30# else
31 return true;
32# endif
33}
34
35#else
36
37template <class T, class WhatFor>
38constexpr bool possible_reflectable(int) noexcept {
39 // negative answer here won't change behaviour in PFR-dependent libraries(like Fusion)
40 return false;
41}
42
43#endif
44
45}}} // namespace boost::pfr::detail
46
47#endif // BOOST_PFR_DETAIL_POSSIBLE_REFLECTABLE_HPP
48
49
50

source code of boost/libs/pfr/include/boost/pfr/detail/possible_reflectable.hpp