Possible Duplicate:
What are the differences between typedef and using in C++11?
The following code compiles and runs. My question is what is the difference between the "typedef" and "using" method for renaming the template specialization?
template<typename T>
struct myTempl{
T val;
};
int main (int, char const *[])
{
using templ_i = myTempl<int>;
templ_i i;
i.val=4;
typedef myTempl<float> templ_f;
templ_f f;
f.val=5.3;
return 0;
}
Edit:
If there is no difference, which one would you prefer? / Why was the using ... = ... version introduced?
using
that is not a template is not really the use-case this was introduced for. – Partainusing
to write type alias is more consistent with new C++11 style. The phrase is from Herb Sutter herbsutter.com/2013/08/12/… – Horny