相关疑难解决方法(0)

如何检查类是否在C++ 11中指定了嵌套类定义或typedef?

在我的项目中,我想实现一些现有更大类的模板代理类.现有的类是库类,因此无法修改它们.在大多数情况下,客户端不知道对象是代理类或更大类的实例.但是,在某些情况下,客户必须知道详细的课程信息.由于代理类本身就是一个模板类,我不认为通过类名简单的函数重载可以解决这个问题.我认为可能的解决方案是在代理类中添加内部嵌套类或typedef,并且客户端检查是否存在此类/ typedef以获取类信息.我的问题是:如何检查类是否在C++ 11中指定了嵌套类定义或typedef?

以下代码显示了一个示例:

#include <iostream>
#include <functional>
#include <string>
#include <vector>
#include <type_traits>

typedef std::string CBig1;  //  use string for demonstration
typedef std::string CBig2;  //  use string for demonstration

//class CBig1;   // the bigger class 1, codes of which can not be changed
//class CBig2;   // the bigger class 2, codes of which can not be changed

template <typename _Big, typename _Other>
class CProxy
{
public:
    struct proxy_tag { };
};

//  how to implement this ?
//  the …
Run Code Online (Sandbox Code Playgroud)

c++ templates typedef c++11

8
推荐指数
2
解决办法
4047
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1

typedef ×1