make_pair(1, "Test")有错吗?
其实问题就是make_pair函数模版的两个形参应该传引用还是传值的问题。
make_pair(1, "Test")在VC6中不能通过,除非改成make_pair<int, const char *>(1, "Test")或者make_pair(1, (const char *)"Test")。但它可以在VC7和Dev C++下通过。究其原因,VC6中它的两个形参是传引用的,而VC7是传值,Dev C++默认是传值,除非改一个#define值。Dev中的注释是这样写的:
The standard requires that the objects be passed by reference-to-const,
but LWG issue #181 says they should be passed by const value. We follow
the LWG by default.
查了一下ISO14882,确实是要传引用的。
LWG是指什么?我猜猜是不是Library Writer's Guide?哪里可以找到?
这个问题本身没有什么太大的意思,不过我很希望能听听大家对这个问题的看法。