Question: I am looking for a way to define automagically a unique object/symbol name based on a type, like illustrated in the following example, where `MEMBER(TypeName)` is something (macro/whatever...) that represents/expands to a unique object identifier, which identifier is defined from `TypeName`.

```
class A { int i; };
class B { int i; };
class X
{
    A MEMBER(A);
    B MEMBER(B);
    X()
    {
        MEMBER(A).i = 1;
        MEMBER(B).i = 2;
    }
};

```

I first tried using the following simple macro to do this:

```
#define MEMBER(TypeName)    m_ ## TypeName

```

which works great, as long as `TypeName` is not a fully qualified name such as `NameSpace::Type`; so I am still looking for a solution working with fully qualified type names.

Note1: the syntax for definition and use of members of class `X` described above is given only to clarify my needs; the solution may involve a totally different way to define and use the members.  

Note2: members of class `X` must not be static.  

Note3: access to members within class `X` must be fast; a compile-time solution is preferable.  

Note4: class `X` cannot contain more than one member of the same type.  

Thanks for help.

Answer: 
If names are a hassle then let's get rid of them completely using tuples:

```
#include <tuple>

class A: public std::tuple<int>{};
class B: public std::tuple<int>{};

class X: std::tuple<A,B> {
public:
   X() {
     std::get<int>(std::get<A>(*this)) = 1;
     std::get<int>(std::get<B>(*this)) = 2;
   }
};

```
```
#define DECL_NMEMBER(NameSpace, TypeName) NameSpace::TypeName m_##NameSpace##_##TypeName;
#define NMEMBER(NameSpace, TypeName) m_##NameSpace##_##TypeName
#define DECL_MEMBER(TypeName) DECL_NMEMBER(, TypeName)
#define MEMBER(TypeName) NMEMBER(, TypeName)

namespace N 
{
class A { public: int i; };
class B { public: int i; };
}

class C { public: int i; };

class X
{
    DECL_NMEMBER(N, A)      // N::A
    DECL_NMEMBER(N, B)      // N::B
    DECL_MEMBER(C)          // C
    DECL_NMEMBER(std, string)   // std::string
    DECL_MEMBER(wstring)    // std::wstring (using namespace std)
    X()
    {
        NMEMBER(N, A).i = 1;
        NMEMBER(N, B).i = 2;
        MEMBER(C).i = 5;
        NMEMBER(std, string) = "test";
        MEMBER(wstring) = L"test2";
    }
};

```

but for some types like `vector<T>` you need make some additional macros(
there are no perfect solution I guess