SFINAE check for operator+=

前端 未结 4 572
无人共我
无人共我 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:54

    You need an lvalue on the left hand side of += but your solution has an xvalue. As dyp has stated in the comments, you can use declval to get an lvalue. This works fine (just tested it):

    template() += std::declval())>
    void foo(T a, T b, ...)
    {
    }
    

提交回复
热议问题