Date: Tue, 22 Feb 2022 21:15:11 +0100
Hi,
I've recently stumbled upon a case where I wanted to use "variadic CRTP":
template <class Derived, class T>
class SBase
{
public:
void foo(T t) { static_cast<Derived *>(this)->data.use(t); }
};
template <class ... X>
class S : public SBase<S<X...>, X>...
{
Data data;
};
Something that I would've also liked to do was to have S befriend all of
its bases (as they need to access the private `data` member). It doesn't
sound however like it's possible *directly*: friend declarations are not
expansions loci for packs.
Is there any specific reason why variadic friends aren't a thing? (In
other words, is it a "remnant", like using before C++17; or is it a
deliberate choice?).
Thank you,
I've recently stumbled upon a case where I wanted to use "variadic CRTP":
template <class Derived, class T>
class SBase
{
public:
void foo(T t) { static_cast<Derived *>(this)->data.use(t); }
};
template <class ... X>
class S : public SBase<S<X...>, X>...
{
Data data;
};
Something that I would've also liked to do was to have S befriend all of
its bases (as they need to access the private `data` member). It doesn't
sound however like it's possible *directly*: friend declarations are not
expansions loci for packs.
Is there any specific reason why variadic friends aren't a thing? (In
other words, is it a "remnant", like using before C++17; or is it a
deliberate choice?).
Thank you,
-- Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
Received on 2022-02-22 20:15:18