S
subramanian100in
For a type T, consider vector<T>::value_type. When is this member
'value_type' useful; in other words, when is the use of value_type
unavoidable?
Kindly clarify.
The reason for asking this question is the following:
For a particular type T, say std::string, Suppose I use,
vector<string>::value_type obj;
But, to initialize or assign a value to 'obj', we have to know the
actual type T. So we can simply declare
string obj;
In this example, the need for value_type is AVOIDABLE.
But there should be some genuine situation wherein the use of
value_type is UNAVOIDABLE. I am unable to come up with an example for
this unavoidable situation. Please clarify.
Thanks
V.Subramanian
'value_type' useful; in other words, when is the use of value_type
unavoidable?
Kindly clarify.
The reason for asking this question is the following:
For a particular type T, say std::string, Suppose I use,
vector<string>::value_type obj;
But, to initialize or assign a value to 'obj', we have to know the
actual type T. So we can simply declare
string obj;
In this example, the need for value_type is AVOIDABLE.
But there should be some genuine situation wherein the use of
value_type is UNAVOIDABLE. I am unable to come up with an example for
this unavoidable situation. Please clarify.
Thanks
V.Subramanian