What do you call this template constructor?

Possible duplicate:
C ++ call explicit template constructor

Hi,

template <typename T>
class testing
{
public:

    template <typename R>
    testing()
    {
       // constructor A
    }

    template <typename R>
    testing(const R&)
    {
       // constructor B
    }
};

What is the syntax for calling constructor A?

I will need a type that will be passed during the constructor call. Is there any way to call this? constructor B is a workaround, since I need to know the type not the whole object.

Thank,

Stephen

+3
source share
2 answers

you can create a workaround:

template<class A>
testing(boost::mpl::identity<A>);

// and instantiate like this
testing(boost::mpl::identity<A>());

I asked a very similar question before C ++ to call an explicit template constructor

+3
source

. T, , , T, R.

: :

( B). , .

+2

Source: https://habr.com/ru/post/1752996/


All Articles