I have a global static std::vector<Type>
, and a struct which will hopefully select from one of the elements.
typedef struct
{
bool initial
bool opening;
std::string friendly_name;
} Type;
using TypeVec = std::vector<Type>;
static const TypeVec starting_types
{
{ true, true, "Open" },
{ true, false, "Close" },
...
};
typedef struct
{
Type type;
} SessionInfo;
Now the SessionInfo struct will choose one of the types in the starting_types. If I write
SessionInfo session;
session->type = starting_types.at (0);
This will create a copy of the first element. I want to do the equivalent of auto&
thus:
auto& type = starting_types.at (0);
But don't know how to save it into SessionInfo::type
.