If I code this
std::map<int, char> example = { (1,'a'),
(2, 'b'),
(3, 'c') };
then g++ says to me
deducing from brace-enclosed initializer list requires #include <initializer_list>
in C++98 ‘example’ must be initialized by constructor, not by ‘{...}’
and that annoys me slightly because the constructor is run-time and can, theoretically fail.
Sure, if it does, it will fail quickly and ought to do so consistently, so that I ought to quickly locate & correct the problem.
But, still, I am curious - is there anyway to initialize map, vector, etc, at compile time?
Edit: I should have said that I am developing for embedded systems. Not all processors will have a C++0x compiler. The most popular probably will, but I don't want to encounter a gotcha & have to maintain 2 version s of the code.
As to Boost, I am undecided. They are wishy-washy on the use of their Finite State Machine classes in embedded systems, so that is actually what I am coding here, Event/State/Fsm classes.
Sigh, I guess I'd better just play it safe, but I hope that this discussion has been helpful for others.