Say we have a class definition
class Foo {...};
I know we can reuse its definition with using
or typedef
using Bar = Foo; // or typedef Foo Bar;
But they are treat as a same type, that is to say the compiler treat following as redefinition
void fun(const Foo&) { cout<<"It is Foo"<<endl; }
void fun(const Bar&) { cout<<"It is Bar"<<endl; }
Is there any possible or work around we can reuse definition that compiler treat as different types
Thanks for your solution and discussion Here are some details of my case: classes would declare their related type. and the type could be the same.
struct MyFoo { using type = SomeRelated; };
struct MyBar { using type = SomeRelated; };
Another class would be contructed with the related type of above classes and I want the constructor can distinguish from them
struct MyClass
{
MyClass(const MyFoo::type&) {cout<<"ctor from MyFoo"<<endl;}
MyClass(const MyBar::type&) {cout<<"ctor from MyBar"<<endl;}
};