Variadic Templates – Recursion – Initializer Lists.

Discussion in 'C++' started by Kenshin, Dec 9, 2009.

  1. Kenshin

    Kenshin Guest

    Seems to me like the only way to write functions/classes taking
    variadic templates is by recursion. Is that true? Can the below work,
    for iteration?

    template<class… T>
    auto func(const T&… t){

    std::initializer_list<?> ilist = {t…}; //what should go here <?>//
    for(const auto& arg : ilist)
    //use arg//
    }
    Kenshin, Dec 9, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Walters
    Replies:
    2
    Views:
    508
    Ben Pfaff
    Feb 13, 2004
  2. Ross A. Finlayson
    Replies:
    19
    Views:
    581
    Keith Thompson
    Mar 10, 2005
  3. Replies:
    2
    Views:
    332
    Dave Thompson
    Feb 27, 2006
  4. Replies:
    5
    Views:
    351
  5. Valeriu Catina

    c++0x variadic templates

    Valeriu Catina, Mar 13, 2008, in forum: C++
    Replies:
    3
    Views:
    595
    Erik Wikström
    Mar 13, 2008
Loading...

Share This Page