
I really cannot follow this.
If the container is type erased, how do you get that information you are alluding to back out?
Here's a very rough sketch demonstrating just one member (set::count). Many details are ignored, obviously.
template<typename ValueType> struct abstract_set
{
typedef ValueType key_type;
typedef ValueType value_type;
typedef std::size_t size_type;
// etc.
template<typename GenericSet>
abstract_set(GenericSet const & set)
: m_holder(new holder<GenericSet>(set))
{}
size_type count(value_type const & value) const
{ return m_holder->count(value); }
private:
struct holder_base
{
virtual size_t count(value_type const &) const = 0;
};
template<typename GenericSet>
struct holder : holder_base
{
holder(GenericSet const & set) : m_container(set) {}
virtual size_t count(value_type const & value) const
{ return m_container.count(value); }
private:
GenericSet const & m_container;
};
boost::shared_ptr
There are plenty of papers and implementations of any_iterator out there. Why is that not sufficient for your needs?
I want the container, not just an iterator. I might want to test for membership or add elements to the container.