I have a class that looks like this
struct A {
double a1;
int b1;
double a2;
int b2;
};
I have to read off of a file values for a1
, b1
, a2
, and b2
. Most of the time all four numbers are on the file, but sometimes there are only two numbers.
When there are two numbers, I want to store the values in a1
, and b1
and I want to store "nothing" in a2
and b2
. If a2
and b2
were pointers, I could just assign them to be nullptr
, but they are not pointers.
Is there something I can store in double
and int
variables to indicate that 'nothing' is stored?
I know Boost.Optional
is available, but I'm trying to avoid that library.