boostorg / pfr

std::tuple like methods for user defined types without any macro or boilerplate code
https://boost.org/libs/pfr
Boost Software License 1.0
1.34k stars 161 forks source link

Addressing the limitation of get_name #152

Closed schaumb closed 10 months ago

schaumb commented 12 months ago

resolves #151

schaumb commented 12 months ago

I found another way to work "fake object" without requiring C++20 (template variable):

template<class T>
struct X {
   const T value;
   static const X<T> report_if_you_see_link_error_with_this_object; // this is not defined, only declared. equivalent with template varaible
};

template <class T>
constexpr const T& fake_object() noexcept {
    return X<T>::report_if_you_see_link_error_with_this_object.value;
}

This is equivalent to prf::detail::unsafe_declval without the nullptr dereference hack.

I created already the changes. Can I try to apply these modifications too?

What do you think @denzor200 ?

apolukhin commented 10 months ago

Looks very good!

Many thanks for the PR!