LINUX.ORG.RU

Помогите упростить шаблонную функцию

 ,


0

1
    // определение
    template< template< class, class > class Container >
    void Initialize( const Container< std::string, std::allocator< std::string > > &hosts )
    {
        typename Container< std::string, std::allocator< std::string > >::const_iterator it = hosts.begin();
    }

    // Вызов
    list< string > hosts;
    Initialize( hosts );

Как укоротить?

Ответ на: комментарий от anonymous

typename Container< std::string, std::allocator< std::string > >::const_iterator
Чтобы получилось как-то так: typename Container<_T, _A >::const_iterator

nerdogeek
() автор топика

так ?

template< class Container >
void Initialize( const Container &hosts )
    {
        typename Container::const_iterator it = hosts.begin();
    }

    // Вызов
list< string > hosts;
Initialize( hosts );

Vinick ★★
()
Ответ на: комментарий от Vinick

Блин точно. Что-то я перенаркоманил с темплейтами. Спасибо :)

nerdogeek
() автор топика

Опять педогрек...

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.