clang-concepts-monorepo icon indicating copy to clipboard operation
clang-concepts-monorepo copied to clipboard

auto type deduction

Open milos94 opened this issue 5 years ago • 2 comments

Maybe my understanding of concepts is not good enough, but I'm having this issue. https://godbolt.org/z/ThKZu5 As seen in the example parameter declared as Employee auto && is deduced as Employee auto (because of std::decay_t) instead of CT::CTEmployee. The commented out version works fine, where concepts are template parameters. So my question is does the type deduction not happen here? Or better when does evaluation of concepts happen?

milos94 avatar Nov 05 '19 09:11 milos94

Please verify, if I correctly minimized your example to pin down the issue. https://godbolt.org/z/OzT00u

uap-universe avatar Nov 05 '19 14:11 uap-universe

Yes, that's about it (sorry I didn't post something like this originally). Don't know if it helps but having a concrete type, or template argument, as type for the first parameter works fine. eg. template<typename T> void fun(T&& x, Bar<std::decay_t<decltype(x)>> auto & y); template <Foo F> void fun(F&& x, Bar<std::decay_t<decltype(x)>> auto & y) { } void fun(FooImpl & x, Bar<std::decay_t<decltype(x)>> auto & y); So it seems that it's auto that's causing issues.

milos94 avatar Nov 05 '19 17:11 milos94