KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Consider the following program: #include <cstddef> #include <cstdio> void f(char const*&&) { std::puts("char const*&&"); } // (1) void f(char const* const&) { std::puts("char const* const&"); } // (2) template <std::size_t N> void f(char const (&)[N]) { std::puts("char const(&)[N]"); } // (3) int main() { const char data[] = "a"; f(data); } Which f should be called? Why? The latest released versions of three compilers disagree on the answer to this question: (1) is called when the program is compiled using g++ 4.5.2 (2) is called when the program is compiled using Visual C++ 2010 SP1 (3) is called when the program is compiled using Clang 3.0 (trunk 127530) Have the overload resolution rules changed substantially in different C++0x drafts? Or, are two of these compilers really just completely wrong? Which overload is the correct overload to be selected per the latest C++0x draft?
Tags (comma-separated)
Save Edits
Cancel