相关疑难解决方法(0)

如何检测方法是否是虚拟的?

我试图找出一个方法来查找方法是否是virtual:(https://ideone.com/9pfaCZ)

// Several structs which should fail depending if T::f is virtual or not.
template <typename T> struct Dvf : T { void f() final; };
template <typename T> struct Dvo : T { void f() override; };
template <typename T> struct Dnv : T { void f() = delete; };

template <typename U>
class has_virtual_f
{
private:
    template <std::size_t N> struct helper {};
    template <typename T>
    static std::uint8_t check(helper<sizeof(Dvf<T>)>*);
    template<typename T> static std::uint16_t check(...);
public: …
Run Code Online (Sandbox Code Playgroud)

c++ virtual-functions sfinae type-traits c++11

29
推荐指数
2
解决办法
1908
查看次数

标签 统计

c++ ×1

c++11 ×1

sfinae ×1

type-traits ×1

virtual-functions ×1