Во-первых: [list] [*][code]test_container[/code] в следующем коде — это функция, которая используется только для целей «отладки». В моем рабочем проекте нет никакой реальной пользы.
[*]Настоящая функция называется foreach (см. последний код в этом вопросе). )
[*][code]foreach[/code] — это функция, которая возвращает std::string представление контейнера (после этого исправления я заставлю ее работать и с массивами int)
[*]Даже представление foreach здесь минимизировано для лучшего понимания: здесь оно похоже на test_container, с небольшими отличиями. [/list]
Итак, у меня есть этот код: [code]#include #include #include #include #include
// Specialization of a template for types with template arguments template struct has_template_argument { static const bool value = !std::is_same::value; };
// Function to verify if the variable has a template argument template bool has_template_arg(const T&) { return has_template_argument::value; }
// The test collection funtion. template std::string test_container(const T& container) { std::stringstream listn;