On Tue, 2 Apr 2024, Jonathan Wakely wrote:

> On Tue, 2 Apr 2024 at 18:00, Pilar Latiesa wrote:
> >
> > Just out of curiosity: would this also work?
> >
> > template<typename _Tp, typename _Disc>
> > struct _Absent {};
> >
> > template<bool _Present, typename _Tp, typename _Disc = decltype([]{})>
> > using __maybe_present_t = __conditional_t<_Present, _Tp, _Absent<_Tp, 
> > _Disc>>;
> >
> > That would avoid having to type 0, 1, ... manually.
> 
> This is subjectively horrible and, more objectively, would create
> longer mangled names and additional RTTI.

Yeah, it's a neat trick but probably not appropriate to use within the
standard library.

Another reason to avoid it is that GCC's support for lambdas within
template arguments has some known bugs (e.g. PR107457 but that should
hopefully be fixed soon).

Reply via email to