"Diwa" <> wrote in message
news: oups.com...
> Does the "value" type (value as in key-value pair )of "std::map"
> require a default ctor even if it is not used ?
It is used, you just don't see it being used by the mere use of a std::map

. As it is used, it is also needed.
> int main()
> {
> std::map<std::string, FieldType> newOrderFields; // fieldname &
> its type
>
> newOrderFields["aotag"] = FieldType('S', 4, true); // <---------
> Line 2 uses non default ctor
Actually, think about what std::map:

perator[] does. It needs to return a
reference to the value. But the value doesn't yet exist, so it has to create
one before it is able to return a reference to it. What your line of code
does is create a default-constructed FieldType (inside map:

perator[]),
which is then overwritten with a temporary constructed FieldType (your
FieldType('S', 4, true) expression) by the use of the (auto-generated)
assignment operator.
- Sylvester