TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25144 13
noexcept, R (P::*)(Args...) volatile>,
std::conditional_t<is_noexcept, R (P::*)(Args...) noexcept, R (P::*)(Args...)>>>;
};
template<bool is_const, bool is_volatile, bool is_noexcept, typename R, typename P, typename...Args>
using assemble_ptr_to_member_t = assemble_ptr_to_member<is_const, is_volatile, is_noexcept, R, P, Args...>::ptr;

consteval std::meta::info to_ptr_manual(std::meta::info thing) {
bool is_noexcept = std::meta::is_noexcept(thing);
bool is_const = std::meta::is_const(thing);
bool is_volatile = std::meta::is_const(thing);
auto return_t = std::meta::return_type_of(thing);
auto parameters = parameters_of(type_of(thing));
auto parent = type_of(parent_of(thing));
std::vector<std::meta::info> template_args;
if(is_const) {
template_args.push_back(std::meta::reflect_constant(true));
} else {
template_args.push_back(std::meta::reflect_constant(false));
}
if(is_volatile) {
template_args.push_back(std::meta::reflect_constant(true));
} else {
template_args.push_back(std::meta::reflect_constant(false));
}
if(is_volatile) {
template_args.push_back(std::meta::reflect_constant(true));
} else {
template_args.push_back(std::meta::reflect_constant(false));
}
template_args.push_back(return_t);
template_args.push_back(parent);
template_args.append_range(parameters);
return substitute(^^assemble_ptr_to_member_t, template_args);
}

 

For the curious: https://godbolt.org/z/4Gs3n4qa6

The standard could help here if either `add_pointer` got extended, or a new metafunction got invented.

https://redd.it/1t66mbc
@r_cpp
godbolt.org Compiler Explorer - C++ (x86-64 gcc 16.1) struct showcase { void mem_fun() const {}; void looks_like_a_free_function() {}; }; constexpr std::meta::info mem_fun_refl = ^^showcase::mem_fun; constexpr std::meta::info mem_fun_ptr_refl = add_pointer(type_of(mem_fun_refl)); static_assert(mem_fun_ptr_refl…
More from @r_cpp
  1. Oct 3, 2026Teodorescu - [https://youtu.be/vVFFW6hoG1Y](https://youtu.be/vVFFW6hoG1Y) * Demystifying C…
  2. Oct 3, 2026New C++ Conference Videos Released This Month - September 2026 (Updated To Include Videos…
  3. Oct 3, 2026HPX 2.0.0 RC1 Released! – The HPX Project HPX is a general-purpose parallel C++ runtime sy…
  4. Oct 3, 2026[PLDI'26] Persistent Iterators with Value Semantics https://www.youtube.com/watch?v=cq33C5…
  5. Oct 3, 2026A Cross-Toolkit Timeline Control, Wed, Oct 14, 2026, 6:00 PM https://www.meetup.com/utah-c…
  6. Oct 3, 2026Upcoming C++ User Group meetings in October https://meetingcpp.com/meetingcpp/news/items/U…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →