On Monday, 16 May 2016 07:40:19 UTC+3, Alf P. Steinbach wrote:
> I just coded up this and I wonder if there's much wrong with this code,
> and/or improvements to the design, and/or kind words about my hairdo?
>
Seems fine on first glance. Why you decided to write another 'optional'
(AKA 'fallible' and 'nullable')? Would be more worth of it if you tried
to achieve constexprness of it. Maybe go full way and use a bool instead
of pointer. It will result with tiniest optional being 2 bytes instead of
16 on lot of platforms.
> I don't have any test cases for this, at all.
>
> And that's another thing I wonder about: how would one go about testing
> code like this? I'm not even sure of requirements on template param.
Easiest might be to install boost and get some unit tests for rather
similar thing (IIRC in $(boost_root)/libs/optional/test).