On 28 November 2022 10:17:46 CET, Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
On Sun, Nov 27, 2022 at 10:19 PM Frederick Virchanza Gotham
<cauldwell.thomas@gmail.com> wrote:
template<class... Bases>
auto close(void)
{
if constexpr (requires { &Nth< 0u,Bases...>::close; }) return &Nth< 0u,Bases...>::close;
else if constexpr (requires { &Nth< 1u,Bases...>::close; }) return &Nth< 1u,Bases...>::close;
<snip>
As a stepping-stone to making something like the above possible, what
if we could give arbitrary words (or arbitrary identifiers) as
template parameters? Something like as follows:
template<identifier K, class T>
constexpr auto GetMemberAddress(T const &t)
{
return &T::K;
}
So then we could do:
#include <string>
int main(void)
{
std::string str;
auto f = GetMemberAddress<"size">(str);
return (str.*f)();
}
Has there ever been any talk about allowing arbitrary
strings/words/identifiers as template parameters?