From 75fab4c80ddb8225f2cb2038c2881735c490dc76 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 28 Aug 2020 13:30:15 -0400 Subject: [PATCH] Decltype --- _posts/2020-08-05-static-polymorphism.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_posts/2020-08-05-static-polymorphism.md b/_posts/2020-08-05-static-polymorphism.md index d41646f..e014f25 100644 --- a/_posts/2020-08-05-static-polymorphism.md +++ b/_posts/2020-08-05-static-polymorphism.md @@ -343,3 +343,10 @@ mostly please just use concepts. Worth acknowledging that C++ can do interesting things with `protected`, `friend`, and others, that Rust can't. However, Rust can limit trait implementations to current crate ("sealed traits"), where C++ concepts are purely duck typing. + +# decltype and compiler-named types + +Rust has some types named by the compiler, but inaccessible in traits; can't return `impl SomeTrait` +from traits. Can return `impl Future` from free functions and structs, but traits can't use +compiler-generated types (associated types still need to name the type). C++ doesn't appear to have +the same restrictions.