I am probably totally off base on this, but I'm coming from c# so I apologize in advance.

First, a little bit about what I'm trying to do. I have a factory base class defined in my code as 

```
template<typename _Ty>
class Factory
{
public:
    virtual std::shared_ptr<_Ty> Create() = 0;
};

```

What I want to do then is have a list of factories (say a stl vector or list) and be able to then search for them by the template type. So far I've figured out I need a vector or list of a containing type of some sort so I came up with:

```
class FactoryContainer
{
    struct FactoryConcept {
        virtual ~FactoryConcept() {}
    };

    template< typename _Ty > struct FactoryModel : FactoryConcept {
        FactoryModel( const _Ty& t ) : factory( t ) {}
        virtual ~FactoryModel() {}
    private:
        _Ty factory;
    };
    std::shared_ptr<FactoryConcept> factory;

public:
    template< typename _Ty > FactoryContainer( const _Ty& _factory ) :
        factory( new FactoryModel<_Ty>( _factory ) ) {}
};

```

I'd like to include some kind of method then in the container to compare type, something along the lines of 

```
template<typename _Ty> bool isType(){...}

```

but I have *no* idea how to implement that, or if I'm even on the right track there with determining type after using type erasure.

EDIT:
After multiple comments about this being an XY problem, I've decided to reemphasize what I'm doing (which I did state).

I want to have an stl container of type Factory (including any and all instantiated template types) and be able to pluck one out BY the template type. To me, the best way *I* see to do this (which may not be *the best way*) is to use a type encapsulating container class, and have it able to respond if the contained type is infact using the provided template type. If it is not, then give up. I can't use dynamic\_cast as suggested as at the time I'm trying to figure it out, I don't have a pointer to either type. I'm looking into typeid now, and hope it'll solve my problems, but I am still waiting for another possible answer.

EDIT 2:
After playing with several answers, I've found nothing that quite meets my requirements. Here's the requirements in a nutshell:

base class template:

```
template<typename FactoryType>
class Factory
{
public:
    virtual std::shared_ptr<FactoryType> Create() = 0;
    virtual ~Factory(){}
};

```

factory manager class:

```
class Manager
{
    static std::shared_ptr<Manager> singleton;
public:
    static std::shared_ptr<Manager> getInstance()
    {
        if (!singleton) singleton = shared_ptr<Manager>(new Manager);
        return singleton;
    }
    template<typename FactoryType>
    Factory<FactoryType>& getFactory()
    {
        //Pick a factory here by the type and return it by reference
        //life cycle is handled by the manager
    }
};

```

Manager will be known about by both the core executable and by various dlls. The possible types for the factories will not be known at the time that Manager is compiled, and it is referenced by code that has no knowledge of each other. It is possible, and likely, to have factories loaded in here that I don't and won't know about, as many of those are being made by someone else and put in a dll.