Emi*_*ier 6 c++ containers boost stl boilerplate
在标准库或Boost中是否存在某种实用程序基类,用于使用所需的typedef(size_type,value_type等)填充自定义STL兼容的Sequence.我正在考虑像boost :: iterator_facade这样的东西,但对于容器.
我打算自己卷起来,但是想确保这样的事情还没有存在.
更新:
这是我提出的实用程序基类,以防任何人发现它有用:
template <class C>
class ContainerAdapter
{
public:
typedef C::value_type value_type;
typedef C::reference reference;
typedef C::const_reference const_reference;
typedef C::const_iterator iterator;
typedef C::const_iterator const_iterator;
typedef C::difference_type difference_type;
typedef C::size_type size_type;
protected:
typedef C::container_type;
};
// Usage
class MyCustomContainer : public ContainerAdapter< std::vector<int> >
{
...
};
Run Code Online (Sandbox Code Playgroud)
ContainerAdapter简单地"回应"自定义容器的基础容器的嵌套typedef.真的没有什么可以做的.