If I typedef some type within a struct (functor), is the scope of the typedef local to the struct?
Consider the following example where I have typdef’ed foo to be an int and a double in the two separate functors. Is this example correct?
template <typename T>
struct firstfunctor
{
typedef int foo;
foo operator()(const foo& a, const foo& b)
{
return /*whatever*/
}
};
template <typename T>
struct secondfunctor
{
typedef double foo;
foo operator()(const foo& a, const foo& b)
{
return /*whatever*/
}
};
Yes, typedefs are scoped, and you define the member types
firstfunctor::fooandsecondfunctor::foo, respectively.