123456789101112131415161718192021222324252627282930313233343536 |
- // Copyright (c) 2023 Bela Schaum, X-Ryl669, 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)
- // Initial implementation by Bela Schaum, https://github.com/schaumb
- // The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
- //
- #ifndef BHO_PFR_DETAIL_FAKE_OBJECT_HPP
- #define BHO_PFR_DETAIL_FAKE_OBJECT_HPP
- #pragma once
- #include <asio2/bho/pfr/detail/config.hpp>
- namespace bho { namespace pfr { namespace detail {
- // This variable serves as a compile-time assert. If you see any error here, then
- // you're probably using `bho::pfr::get_name()` or `bho::pfr::names_as_array()` with a non-external linkage type.
- template <class T>
- extern const T passed_type_has_no_external_linkage;
- // For returning non default constructible types, it's exclusively used in member name retrieval.
- //
- // Neither std::declval nor bho::pfr::detail::unsafe_declval are usable there.
- // Limitation - T should have external linkage.
- template <class T>
- constexpr const T& fake_object() noexcept {
- return passed_type_has_no_external_linkage<T>;
- }
- }}} // namespace bho::pfr::detail
- #endif // BHO_PFR_DETAIL_FAKE_OBJECT_HPP
|