Transforming a parameterization by two classes to a parameterization by one class

后端 未结 3 2155
感情败类
感情败类 2021-01-22 14:33

The following code has a little bit of unpleasantness.

#include 

template struct PA1 {}; template struct QA1          


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 15:28

    If you want type A to be automatically inferred, then no such modification is possible unless you have fn take an argument of type A (or A& or A* etc) and consequently force the user to pass in a value of that type.

    On the other hand, if you don't mind forcing the caller to specify the template argument explicitly, then that syntax is already fine.

    There's no happy medium.

提交回复
热议问题