Parameter pack of const-references

I have this basic prototype:

1
2
3
4
struct int_wrapper{int i;};

template <const int_wrapper&... IPack>
    void display_all(const int_wrapper&, IPack...);


But when I try to compile it, the compiler says IPack is not a type on the last line. Are packs of references not allowed?
IPack is a value template parameter, not a type template parameter. Does it make sense to say this?
1
2
3
4
void display_all(const int_wrapper&, 2, 79, 400)
{
    //
}
Last edited on
Oh okay....

So is there any way to have a pack of objects?

Edit:
Of one class I mean.
Last edited on
You can do it with some template metaprogramming, but I can't write it down off the top of my head. You might want to consider simple va_lists instead.
Ah, I see. Thanks for the information.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

struct int_wrapper { int i ; /* .... */ } ;

std::ostream& print( const int_wrapper& w ) { return std::cout << '{' << w.i << "} " ; }

std::ostream& print_all() { return std::cout << '\n' ; }

template < typename... T > std::ostream& print_all( const int_wrapper& first, const T&... rest )
{
     print(first) ;
     return print_all( rest... ) ;
}

int main()
{
    int_wrapper a{0}, b{1}, c{2}, d{3} ;
    print_all() ;
    print_all( a ) ;
    print_all( a, b ) ;
    print_all( a, b, c ) ;
    print_all( a, b, c, d ) ;
}

http://ideone.com/nFDQ8i
Topic archived. No new replies allowed.