I have defined a tuple and its indices by creating an enum class:
/** parameter { key ; value1 ; value1 ; } */
using Parameter = std::tuple<unsigned, unsigned, unsigned>;
enum class ParameterKey : std::size_t {
KEY = 0,
VALUE1 = 1,
VALUE2 = 2
};
Now I would like to get a value from this tuple:
const auto& key = std::get<ParameterKey::KEY>(*parameterPointer);
I thought the implicit conversion from int
to std::size_t
is ensured by the : std::size_t
syntax :
enum class ParameterKey : std::size_t {
....
}
but I'm getting this error
error: no matching function for call to ‘get<KEY>(std::tuple<unsigned int, unsigned int, unsigned int>&)’
This works fine, but it's too garrulous:
const auto& key = std::get<static_cast<unsigned>(ParameterKey::KEY)>(*parameterPointer);
get
. – Whiggism: std::size_t
syntax than? – Iiette