I'm having some difficulty wrapping my head around this one, likely because I don't fully understand the underlying mechanics.
I have a struct like the following:
template <class T>
struct A {
int id;
T x;
}
This struct is then used as a type for a shared_ptr:
typedef std::shared_ptr<A> A_ptr;
Which in turn gets stored in a map:
typedef unordered_map<int , A_ptr> AMap;
However, when I compile, I get the following error:
> error: type/value mismatch at argument 1 in template parameter list
> for 'template<class _Tp> class std::shared_ptr' typedef
> std::shared_ptr<A> A_ptr;
I have read other posts about a similar issue, but all of them recommend creating the shared_ptr A inside the struct. I've tried this, even though I can't logically understand why it would help with my problem, but it doesn't work. Any help is appreciated.