Hey folks,
I'm currently trying to make my container wrapper only define some specific member functions if they are supported by the underlying container.
Code:
template<typename Type, template<typename...> typename Container>
class container {
public:
using size_type=typename Container<Type>::size_type;
auto at(size_type position)
-> decltype(std::declval<Container<Type>>()[std::declval<size_type>()]);
};
Sadly it doesn't really work at the moment: my compiler throws hard errors instead of silently removing the overload...
Code:
int main()
{
container<int, std::vector> first; // fine
container<int, std::set> second; // hard error: no operator[] defined
}
It would be nice if someone could point out my mistake! Thanks