From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24505 invoked by alias); 10 Nov 2011 22:08:50 -0000 Received: (qmail 24492 invoked by uid 22791); 10 Nov 2011 22:08:48 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from blu0-omc2-s8.blu0.hotmail.com (HELO blu0-omc2-s8.blu0.hotmail.com) (65.55.111.83) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Nov 2011 22:08:33 +0000 Received: from BLU162-W60 ([65.55.111.71]) by blu0-omc2-s8.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 10 Nov 2011 14:08:32 -0800 Message-ID: From: Nathan Ridge To: , GCC Help Mailing List Subject: RE: [C++11] recursive late-specified return type Date: Thu, 10 Nov 2011 23:37:00 -0000 In-Reply-To: References: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg00109.txt.bz2 > > Could someone please clarify whether the following code (from [1]), > > which GCC trunk rejects, is valid (i.e. the error is a bug) or invalid? > > I can't answer this question, but it will compile if you use > std::common_type<>, from to calculate the return > type.... e.g.: > > [snip] > > I can imagine that the reason your version might not compile is > because you're trying to use the multi-parameter version of sum, in > "decltype (t + sum (p...))" before the multi-parameter version of sum > has been fully declared (as the decltype is part of that declaration); > I dunno whether the compiler is supposed to handle that or not... I am aware that there are workarounds. I would like to know whether my version is valid C++11 or not. The use case that made me search for this issue (and thus find that example on stackoverflow) was the following: template class foo {}; template auto f() -> foo())>; template <> int f<0>(); The idea here is that f<0>() returns int, f<1>() returns foo, f<2>() returns foo>, etc. The errors here are different, so I'm not sure if this is the exact same issue: test.cpp:4:26: error: 'f' was not declared in this scope test.cpp:4:26: error: 'f' was not declared in this scope test.cpp:4:37: error: template argument 1 is invalid test.cpp:7:6: error: expected initializer before '<' token Does anyone know whether this should be valid? The workaround for this is more complicated (you need a separate metafunction that computes the return type). Thanks, Nate =20=09=09=20=09=20=20=20=09=09=20=20