{"action":"created","issue":{"url":"https://api.github.com/repos/ericniebler/stl2/issues/572","repository_url":"https://api.github.com/repos/ericniebler/stl2","labels_url":"https://api.github.com/repos/ericniebler/stl2/issues/572/labels{/name}","comments_url":"https://api.github.com/repos/ericniebler/stl2/issues/572/comments","events_url":"https://api.github.com/repos/ericniebler/stl2/issues/572/events","html_url":"https://github.com/ericniebler/stl2/issues/572","id":354089426,"node_id":"MDU6SXNzdWUzNTQwODk0MjY=","number":572,"title":"`std::tie` is currently incompatible with foo_result","user":{"login":"cjdb","id":8622748,"node_id":"MDQ6VXNlcjg2MjI3NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/8622748?v=4","gravatar_id":"","url":"https://api.github.com/users/cjdb","html_url":"https://github.com/cjdb","followers_url":"https://api.github.com/users/cjdb/followers","following_url":"https://api.github.com/users/cjdb/following{/other_user}","gists_url":"https://api.github.com/users/cjdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cjdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjdb/subscriptions","organizations_url":"https://api.github.com/users/cjdb/orgs","repos_url":"https://api.github.com/users/cjdb/repos","events_url":"https://api.github.com/users/cjdb/events{/privacy}","received_events_url":"https://api.github.com/users/cjdb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-26T12:06:04Z","updated_at":"2018-10-17T20:45:44Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"From cmcstl2's partial_sort_copy:\r\n\r\n```cpp\r\nstd::tie(first, r) = ext::copy(std::move(first), last, std::move(r), result_last);\r\n```\r\n\r\nDiagnostic:\r\n\r\n```\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp: In instantiation of ‘constexpr I2 __stl2::__partial_sort_copy_fn::operator()(I1, S1, I2, S2, Comp, Proj1, Proj2) const [with I1 = int*; S1 = int*; I2 = int*; S2 = int*; Comp = __stl2::less<void>; Proj1 = __stl2::identity; Proj2 = __stl2::identity]’:\r\ncmcstl2/test/algorithm/partial_sort_copy.cpp:119:38:   required from here\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:43:25: error: no match for ‘operator=’ (operand types are ‘std::tuple<int*&, int*&>’ and ‘__stl2::copy_result<int*, int*>’)\r\n      std::tie(first, r) =\r\n      ~~~~~~~~~~~~~~~~~~~^\r\n       ext::copy(std::move(first), last, std::move(r), result_last);\r\n       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from /usr/include/c++/8/functional:54,\r\n                 from cmcstl2/include/stl2/functional.hpp:16,\r\n                 from cmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:16,\r\n                 from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\n/usr/include/c++/8/tuple:1209:7: note: candidate: ‘std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(const std::tuple<_T1, _T2>&) [with _T1 = int*&; _T2 = int*&]’\r\n       operator=(const tuple& __in)\r\n       ^~~~~~~~\r\n/usr/include/c++/8/tuple:1209:7: note:   no known conversion for argument 1 from ‘__stl2::copy_result<int*, int*>’ to ‘const std::tuple<int*&, int*&>&’\r\n/usr/include/c++/8/tuple:1216:7: note: candidate: ‘std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::tuple<_T1, _T2>&&) [with _T1 = int*&; _T2 = int*&]’\r\n       operator=(tuple&& __in)\r\n       ^~~~~~~~\r\n/usr/include/c++/8/tuple:1216:7: note:   no known conversion for argument 1 from ‘__stl2::copy_result<int*, int*>’ to ‘std::tuple<int*&, int*&>&&’\r\n/usr/include/c++/8/tuple:1225:9: note: candidate: ‘template<class _U1, class _U2> std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(const std::tuple<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int*&; _T2 = int*&]’\r\n         operator=(const tuple<_U1, _U2>& __in)\r\n         ^~~~~~~~\r\n/usr/include/c++/8/tuple:1225:9: note:   template argument deduction/substitution failed:\r\nIn file included from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:43:25: note:   ‘__stl2::copy_result<int*, int*>’ is not derived from ‘const std::tuple<_T1, _T2>’\r\n      std::tie(first, r) =\r\n      ~~~~~~~~~~~~~~~~~~~^\r\n       ext::copy(std::move(first), last, std::move(r), result_last);\r\n       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from /usr/include/c++/8/functional:54,\r\n                 from cmcstl2/include/stl2/functional.hpp:16,\r\n                 from cmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:16,\r\n                 from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\n/usr/include/c++/8/tuple:1233:9: note: candidate: ‘template<class _U1, class _U2> std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::tuple<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int*&; _T2 = int*&]’\r\n         operator=(tuple<_U1, _U2>&& __in)\r\n         ^~~~~~~~\r\n/usr/include/c++/8/tuple:1233:9: note:   template argument deduction/substitution failed:\r\nIn file included from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:43:25: note:   ‘__stl2::copy_result<int*, int*>’ is not derived from ‘std::tuple<_T1, _T2>’\r\n      std::tie(first, r) =\r\n      ~~~~~~~~~~~~~~~~~~~^\r\n       ext::copy(std::move(first), last, std::move(r), result_last);\r\n       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from /usr/include/c++/8/functional:54,\r\n                 from cmcstl2/include/stl2/functional.hpp:16,\r\n                 from cmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:16,\r\n                 from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\n/usr/include/c++/8/tuple:1241:9: note: candidate: ‘template<class _U1, class _U2> std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int*&; _T2 = int*&]’\r\n         operator=(const pair<_U1, _U2>& __in)\r\n         ^~~~~~~~\r\n/usr/include/c++/8/tuple:1241:9: note:   template argument deduction/substitution failed:\r\nIn file included from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:43:25: note:   ‘__stl2::copy_result<int*, int*>’ is not derived from ‘const std::pair<_T1, _T2>’\r\n      std::tie(first, r) =\r\n      ~~~~~~~~~~~~~~~~~~~^\r\n       ext::copy(std::move(first), last, std::move(r), result_last);\r\n       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from /usr/include/c++/8/functional:54,\r\n                 from cmcstl2/include/stl2/functional.hpp:16,\r\n                 from cmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:16,\r\n                 from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\n/usr/include/c++/8/tuple:1250:9: note: candidate: ‘template<class _U1, class _U2> std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int*&; _T2 = int*&]’\r\n         operator=(pair<_U1, _U2>&& __in)\r\n         ^~~~~~~~\r\n/usr/include/c++/8/tuple:1250:9: note:   template argument deduction/substitution failed:\r\nIn file included from cmcstl2/test/algorithm/partial_sort_copy.cpp:21:\r\ncmcstl2/include/stl2/detail/algorithm/partial_sort_copy.hpp:43:25: note:   ‘__stl2::copy_result<int*, int*>’ is not derived from ‘std::pair<_T1, _T2>’\r\n      std::tie(first, r) =\r\n      ~~~~~~~~~~~~~~~~~~~^\r\n       ext::copy(std::move(first), last, std::move(r), result_last);\r\n       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n```\r\n\r\nA viable solution will possibly need to go through LEWG first, but I am of the opinion that this is a workaround, not the way things should be done:\r\n\r\n```cpp\r\n{\r\n   auto result = ext::copy(std::move(first), last, std::move(r), result_last);\r\n   first = std::move(result.in);\r\n   r = std::move(result.out);\r\n}\r\n```\r\n\r\n### Proposal 1\r\n\r\nMake `copy_result<I, O>`, etc. implicitly convertible to `tuple<I&, O&>` for non-`const` rvalues only.\r\n\r\nI don't expect people to start misusing this particular feature, but I could be naïve.\r\n\r\n### Proposal 2\r\n\r\nAdd exposition-only result types that all result types can inherit from, (e.g. `struct copy_result : __in_out_result<I, O>`), and add a constructor to `std::tuple` for each exposition-only result type:\r\n\r\n```cpp\r\ntemplate<class X>\r\nrequires Same<remove_reference_t<X>, __in_out_result<I, O>> // deliberately not remove_cvref_t\r\ntuple(X&& algorithm_result);\r\n```\r\n\r\nI am not sure of the implications for this one.\r\n\r\n### Proposal 3\r\n\r\nChange `std::tie` so that it returns an object of an exposition-only type that's common to all result types, `std::tuple`, and `std::pair`, and provide constructors for this common type.\r\n\r\nAgain, I'm not sure of the implications, and it's potentially a lot of extra work involved. Having said that, it does feel like the best of the three solutions I've thought of so far, since we can have other yet-to-be-invented types take advantage of `std::tie`."},"comment":{"url":"https://api.github.com/repos/ericniebler/stl2/issues/comments/430783277","html_url":"https://github.com/ericniebler/stl2/issues/572#issuecomment-430783277","issue_url":"https://api.github.com/repos/ericniebler/stl2/issues/572","id":430783277,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDc4MzI3Nw==","user":{"login":"timsong-cpp","id":10905931,"node_id":"MDQ6VXNlcjEwOTA1OTMx","avatar_url":"https://avatars0.githubusercontent.com/u/10905931?v=4","gravatar_id":"","url":"https://api.github.com/users/timsong-cpp","html_url":"https://github.com/timsong-cpp","followers_url":"https://api.github.com/users/timsong-cpp/followers","following_url":"https://api.github.com/users/timsong-cpp/following{/other_user}","gists_url":"https://api.github.com/users/timsong-cpp/gists{/gist_id}","starred_url":"https://api.github.com/users/timsong-cpp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timsong-cpp/subscriptions","organizations_url":"https://api.github.com/users/timsong-cpp/orgs","repos_url":"https://api.github.com/users/timsong-cpp/repos","events_url":"https://api.github.com/users/timsong-cpp/events{/privacy}","received_events_url":"https://api.github.com/users/timsong-cpp/received_events","type":"User","site_admin":false},"created_at":"2018-10-17T20:45:44Z","updated_at":"2018-10-17T20:45:44Z","author_association":"CONTRIBUTOR","body":"It's a language issue that we don't have an SB-equivalent for existing things.  \r\n\r\nI'd say that this is NAD."}}
{"actor":{"display_login":"timsong-cpp"}}