I would like to have a template on container and two tuple types, so that I can merge two following functions into one:
template<typename Container>
void vblock(int row, int col, const Container& container) {
foreach( const typename Container::value_type& item, container ) {
cell(row, col, item);
++row;
}
}
template<typename container, typename T1, typename T2>
void vblock(int row, int col,
const std::list<typename boost::tuple<T1, T2> >& container) {
typedef boost::tuple<T1, T2> Tuple;
foreach( const Tuple& item, container ) {
cell(row, col, item.template get<0>());
cell(row + 1, col, item.template get<1>());
++col;
}
}
template<typename container, typename T1, typename T2>
void vblock(int row, int col,
const std::set<typename boost::tuple<T1, T2> >& container) {
typedef boost::tuple<T1, T2> Tuple;
foreach( const Tuple& item, container ) {
cell(row, col, item.template get<0>());
cell(row + 1, col, item.template get<1>());
++col;
}
}
I have already checked C++ Templates - Specifying a container type and that containers element type that it holds and C++ Template class using STL container and a typedef, but they don't answer my question.
The question simple C++ templates suited for STL Containers is most similar to mine, but I couldn't figure out how to add templates for boost::tuple. Thanks!