saarraz / clang-concepts-monorepo

****** OBSOLETE - CONCEPTS HAS BEEN MERGED INTO CLANG TRUNK AND DEVELOPMENT CONTINUES THERE ****** This fork of llvm-project contains my implementation of C++2a Concepts for the Clang compiler, and will be updated regularly with bug fixes until the whole feature is merged to trunk. Follow the instructions here https://clang.llvm.org/get_started.html to build, then use the flags "-std=c++2a -Xclang -fconcepts-ts" to enable concepts.
27 stars 3 forks source link

auto type deduction #31

Open milos94 opened 4 years ago

milos94 commented 4 years ago

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?

uap-universe commented 4 years ago

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

milos94 commented 4 years ago

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.