list/array of constant pair values at compile time

How do we have a list/array of constant pair values at compile time so it would be passed as two arguments of function invoked repeatedly as many times as the array size ?
the problem arises from restricted enum can have only one value for each member
Hard to understand what you mean, are you looking for something like std::map? :

http://www.cplusplus.com/reference/map/map/
Something like this?

1
2
3
enum MyEnum { enumValue1, enumValue2 };
class MyAssociatedData{ };
std::vector<std::pair<MyEnum, MyAssociatedData>> MyListOfPairs;
is pair and map a run-time /dynamic isn't it?
Last edited on
Why does it matter?
is pair and map a run-time /dynamic isn't it?


I have no idea what you are asking.

Pair is just a template class with 2 members.
Map is just a class providing a binary tree with a key and a value.

These are types just like int or double or std::string.
I think what abdul wants is an associative data structure that is forced to be computed (or at least generated?) at compile-time, in a meta-programming-esque way.
e.g. you could have my_map[3] and it would be determined to be "apple" at compile-time.
I assume something like this is possible, but might require template metaprogramming.
Last edited on
Topic archived. No new replies allowed.