给定一个容器来获取相关的迭代器很容易,例如:
std::vector<double>::iterator i; //An iterator to a std::vector<double>
Run Code Online (Sandbox Code Playgroud)
我想知道在给定迭代器类型的情况下是否有可能推断出"相应容器"的类型(这里我假设每个容器都有一个且只有一个(非常量)迭代器).
更确切地说,我想要一个适用于所有STL容器的模板元函数(无需为每个单个容器手动专门化),例如:
ContainerOf< std::vector<double>::iterator >::type
Run Code Online (Sandbox Code Playgroud)
评估为
std::vector<double>
Run Code Online (Sandbox Code Playgroud)
可能吗?如果没有,为什么?
预先感谢您的任何帮助!