如果是模板类,是否可以隐藏库依赖项?
Is it possible to hide a library dependency if it's a template class?
我有一个使用库B的库A。我希望A的用户使用B库中的模板类。但是A和B有不同的命名空间,是否可以在名称空间中封装/隐藏该类?
我尝试使用pimpl,但是...这是一个模板,所以不知道该如何做。
用于参考我想封装在库中的类是:
namespace anax {
template <typename T>
class Component : public BaseComponent
{
public:
static detail::TypeId GetTypeId()
{
return detail::ClassTypeId<BaseComponent>::GetTypeId<T>();
}
};
}
因此,A的用户必须这样做:
class Position: public anax::Component<Position>
{
float x,y,z;
}
我确切地问的是,是否可以将此anax :: component类封装/隐藏我的名称空间中:
class Position: public myAnamespace::Component<Position>
{
float x,y,z;
}
怎么样:
namespace myAnamespace{
template<class Position>
using Component = anax::Component<Position>;
}
或,在pre-c 11中,
namespace myAnamespace{
template<class Position>
struct Component
{
typedef anax::Component<Position> type;
};
}
namespace anax
{
class Component
{
};
};
namespace b
{
using namespace anax;
class Position : public Component
{
};
};
相关文章:
- 如何从C++中的依赖类型中获得它所依赖的类型
- 这是我尝试让用户将值输入到数组中.然后将其隐藏为大量的星号
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 将依赖名称显式标记为类型名和模板的奇怪之处
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 结构和双指针隐藏在其他结构中,多层混淆
- C++GTKMM gui循环依赖关系
- 通过ccmake在cmake中缓存依赖选项
- 当基类是依赖类型时,这是一个缺陷吗
- 从不同的附加依赖项中识别等同命名的函数
- 在 cpp 文件中隐藏采用模板参数引用的方法
- 如何在 CMake 中对目标依赖项进行分组?
- 是否可以依赖函数范围的静态变量来执行程序关闭期间调用的方法?
- 为什么构建目录中新构建的共享库与安装目录中的副本具有不同的依赖项集?
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 包括订单和隐藏依赖关系
- 隐藏库用户的库依赖关系
- 如果是模板类,是否可以隐藏库依赖项?
- 使用NetBeans在Linux上的共享库中隐藏二级依赖关系
- 是否有任何标准的包含顺序来避免隐藏的依赖关系