In SML, which is a dynamic functional language, there’s a way to create a “one of” data type
datatype element = NONE | Value of Structure;
and now I can use as a return type in function: return either a Structure
or NONE
I didn’t find any way of doing the same in C++ and I tried using an enum
but they only accept constants.
2