Incorrect overload resolution for 2-argument functions

前端 未结 3 387
粉色の甜心
粉色の甜心 2021-01-12 02:30

Let\'s take the following example program:

#include 

namespace half_float
{
    template struct half_expr {};

    struct hal         


        
3条回答
  •  天涯浪人
    2021-01-12 03:19

    A workaround is to specialise _Common_float_type for half and half_expr to be an undefined type, so that SFINAE gets rid of the VS2012 version of atan2.

    namespace std {
        template
        struct _Common_float_type, half_float::half_expr>;
        template
        struct _Common_float_type>;
        template
        struct _Common_float_type, half_float::half>;
        template<>
        struct _Common_float_type;
    }
    

    Note that you have to specialise for all four combinations of half and half_expr, because template specialisation doesn't consider base classes.

提交回复
热议问题