KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Reduced sample code: #include <iostream> template<typename T> void func(T &x) { std::cout << "non-const " << x << std::endl; } template<typename T> void func(const T &x) { std::cout << "const " << x << std::endl; } template<typename ...ARGS> void proxy(ARGS ...args) { func(args...); } int main() { int i = 3; func(i); func(5); func("blah"); proxy(i); proxy(5); proxy("blah"); } Expected output: non-const 3 const 5 const blah non-const 3 const 5 const blah Actual output: non-const 3 const 5 const blah non-const 3 non-const 5 non-const blah So somehow the const qualifier of the function parameter gets lost when put through the variadic template. Why? How can I prevent this? PS: tested with GCC 4.5.1 and SUSE 11.4
Tags (comma-separated)
Save Edits
Cancel