I just read the proposal on return type deduction [1] and it is unclear to meif the following code would be valid:#include <iostream>template<class T> struct B {auto hello() { return std::string{"Hello, I'm a B"}; }void print_me() { std::cout << hello() << std::endl; }};int main() {B<int> b;b.print_me();return 0;}In particular, I wasn't able to find an example there about their usage withinclass templates. Would this be valid code?
Clang also fails and reports: error: function 'hello' with deduced return type cannot be used before it is defined. I'll fill a bug report.
Clang also fails and reports: error: function 'hello' with deduced return type cannot be used before it is defined. I'll fill a bug report.
On Wed, Aug 14, 2013 at 3:26 PM, <jonatha...@gmail.com> wrote:
On Tuesday, August 13, 2013 3:41:00 PM UTC+1, gonza...@gmail.com wrote:I just read the proposal on return type deduction [1] and it is unclear to meif the following code would be valid:#include <iostream>
template<class T> struct B {auto hello() { return std::string{"Hello, I'm a B"}; }void print_me() { std::cout << hello() << std::endl; }};int main() {B<int> b;b.print_me();return 0;}In particular, I wasn't able to find an example there about their usage withinclass templates. Would this be valid code?
I don't see why it wouldn't be valid (although the version of G++ 4.9 I tried it with crashed!)
If a valid code construct doesn't work inside templates then that needs to be stated explicitly, so if the proposal doesn't say it doesn't work in templates then assume it does.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-discussion/.
Why can't it be used in a subsequent member signature? They type has already been deduced.