using SFINAE for template class specialisation

前端 未结 3 769
鱼传尺愫
鱼传尺愫 2020-12-02 17:08

suppose I have these declarations

template class User;
template class Data;

and want to implement

3条回答
  •  醉话见心
    2020-12-02 17:23

    IF the original declaration of User<> can be adapted to

    template class User;
    

    then we can find a solution (following Luc Danton's comment, instead of using std::enable_if)

    template
    struct is_Data : std::false_type {};
    template
    struct is_Data> : std::true_type {};
    
    template
    class User::type >
    { /* ... */ };
    

    However, this doesn't answer the original question, since it requires to change the original definition of User. I'm still waiting for a better answer. This could be one that conclusively demonstrates that no other solution is possible.

提交回复
热议问题