{"action":"opened","issue":{"url":"https://api.github.com/repos/tnie/Timer/issues/2","repository_url":"https://api.github.com/repos/tnie/Timer","labels_url":"https://api.github.com/repos/tnie/Timer/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/tnie/Timer/issues/2/comments","events_url":"https://api.github.com/repos/tnie/Timer/issues/2/events","html_url":"https://github.com/tnie/Timer/issues/2","id":340118372,"node_id":"MDU6SXNzdWUzNDAxMTgzNzI=","number":2,"title":"模板函数匹配优先级？","user":{"login":"tnie","id":5952845,"node_id":"MDQ6VXNlcjU5NTI4NDU=","avatar_url":"https://avatars0.githubusercontent.com/u/5952845?v=4","gravatar_id":"","url":"https://api.github.com/users/tnie","html_url":"https://github.com/tnie","followers_url":"https://api.github.com/users/tnie/followers","following_url":"https://api.github.com/users/tnie/following{/other_user}","gists_url":"https://api.github.com/users/tnie/gists{/gist_id}","starred_url":"https://api.github.com/users/tnie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tnie/subscriptions","organizations_url":"https://api.github.com/users/tnie/orgs","repos_url":"https://api.github.com/users/tnie/repos","events_url":"https://api.github.com/users/tnie/events{/privacy}","received_events_url":"https://api.github.com/users/tnie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-11T07:10:53Z","updated_at":"2018-07-11T07:10:53Z","closed_at":null,"author_association":"OWNER","body":"```cpp\r\ntemplate<typename T> void print_queue(T& q) {\r\n    while (!q.empty()) {\r\n        std::cout << q.top() << \" \";\r\n        q.pop();\r\n    }\r\n    std::cout << '\\n';\r\n}\r\n\r\ntemplate<typename a, typename b> void print_queue(priority_queue<int, a, b> & q) {\r\n    while (!q.empty()) {\r\n        std::cout << q.top() << \"[\" << (q.top() ^ 1) << \"] \";\r\n        q.pop();\r\n    }\r\n    std::cout << '\\n';\r\n}\r\n\r\n\r\nint main()\r\n{\r\n    // 用 lambda 比较元素。\r\n    auto cmp = [](int left, int right) { return (left ^ 1) < (right ^ 1); };\r\n    std::priority_queue<int, std::vector<int>, decltype(cmp)> q3(cmp);\r\n\r\n    for (int n : {1, 8, 5, 6, 3, 4, 0, 9, 7, 2})\r\n        q3.push(n);\r\n\r\n    print_queue(q3);\r\n}\r\n```\r\n\r\n为什么就会优先找第二个了呢？上述用法其实并不涉及特例化，所以就是模板函数匹配优先级喽"}}
{"actor":{"display_login":"tnie"}}