How can I detect whether a type is a visible base of another type?

后端 未结 3 1296
夕颜
夕颜 2021-02-19 17:29

If I do

struct A{};
struct C:private A{};

typedef char (&yes)[1];
typedef char (&no)[2];

template 
struct Host
{
 operato         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-19 18:07

    In order to apply the compile-time overload resolution trick to detect access specifiers, you would at least need that access specifiers are considered at the time overload resolution is done. This is not the case with C++03, so it cannot be done. I believe C++11 changes this so with some artificial conversions and SFINAE you would be able to implement it.

    Update: I'm going over n3242 Overload Resolution section, and I cannot find anything that would indicate that access specifiers are considered for overload resultion at C++11.

提交回复
热议问题