P
pyramus
I am wondering which one should be preferred for creating a local
synonym within a function definition. Let's say I have a type in my
library called MyLib::Foundation::int32, which I can't stand typing all
the time. Should I do:
void foo()
{
typedef MyLib::Foundation::int32 int32;
int32 x = 0;
}
OR:
void bar()
{
using MyLib::Foundation::int32;
int32 x = 0;
}
First, is there any difference between the two, according to the
language standard? A colleague has suggested that typedef would
"override" any other definitions of int32 that might exist, while a
using-declaration may not, but he wasn't sure about this.
If there is a difference, would there be one that you'd prefer as a best
practice? (When restricted to local use within function definitions.)
Thanks in advance
synonym within a function definition. Let's say I have a type in my
library called MyLib::Foundation::int32, which I can't stand typing all
the time. Should I do:
void foo()
{
typedef MyLib::Foundation::int32 int32;
int32 x = 0;
}
OR:
void bar()
{
using MyLib::Foundation::int32;
int32 x = 0;
}
First, is there any difference between the two, according to the
language standard? A colleague has suggested that typedef would
"override" any other definitions of int32 that might exist, while a
using-declaration may not, but he wasn't sure about this.
If there is a difference, would there be one that you'd prefer as a best
practice? (When restricted to local use within function definitions.)
Thanks in advance