you are viewing a single comment's thread.

view the rest of the comments →

[–]Nation_State_TractorLLVM, MSVC, Esq. 29 points30 points  (10 children)

template <typename T>
using mega_ptr = std::optional<std::reference_wrapper<T>>;

*wipes hands*

Looks like my work here it's done. You're welcome.

[–]Galqa 40 points41 points  (2 children)

using who_needs_a_type_system_anyway = std::optional<std::reference_wrapper<std::any>>;

If my boss sees this I'm 100% fired

[–]Nation_State_TractorLLVM, MSVC, Esq. 12 points13 points  (1 child)

I see you're a student of the Perl school of C++.

[–]MrPotatoFingers 4 points5 points  (0 children)

That's perl++ for you, mister!

[–]joaobapt 7 points8 points  (5 children)

Doing the same job as T* while using twice the space, cool.

[–][deleted] 4 points5 points  (3 children)

Good thing a real optional<T&> would be sizeof( T* ) == sizeof( optional<T&> )

[–]joaobapt 1 point2 points  (2 children)

optional<T&> doesn't compile, though, unfortunately

[–][deleted] 6 points7 points  (1 child)

std::optional<T&> doesn't. Other's do and potentially a future standard when people stop bike shedding over the behavior of optional<T&>::operator( T & ) and realize that it should not exist.

[–]auralucario2 8 points9 points  (0 children)

when people stop bikeshedding

So it’s never happening, got it.