Search code examples
c++boostshared-ptrtemplate-templates

How to derive a template template class from boost::enable_shared_from_this?


How can one derive a template class with templated type from boost::enable_shared_from_this?

template<template<class T> class Container>
class Myclass : public boost::enable_shared_from_this<?> {
};

This didn't compile:

template<template<class T> class Container>
class Myclass : public boost::enable_shared_from_this<Myclass<Container<T> > > {
};

Error: 'Myclass' is not a template type.


Solution

  • Since your class is templated by template template parameter - you should use simply Containter.

    template<template<class> class Container>
    class Myclass : public boost::enable_shared_from_this<Myclass<Container> >
    {
    };