SFINAE check for operator+=

前端 未结 4 583
无人共我
无人共我 2021-01-01 21:07

I\'m trying to eliminate an overload from an overload set if operator+= is missing.

I know how to check if T+T is legal :

t         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 21:31

    How about this? it's the method used before std::declval.

    template())>
    void foo(T a, T b, ...)
    {
      a += b;
      std::cout << "foo with +=" << std::endl;
    }
    

提交回复
热议问题