From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10798 invoked by alias); 11 Feb 2013 04:10:48 -0000 Received: (qmail 8465 invoked by uid 48); 11 Feb 2013 04:10:28 -0000 From: "potswa at mac dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/56283] New: std::result_of does not gracefully SFINAE (not define ::type) Date: Mon, 11 Feb 2013 04:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: potswa at mac dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg01014.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56283 Bug #: 56283 Summary: std::result_of does not gracefully SFINAE (not define ::type) Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: potswa@mac.com >>From the spec of std::result_of, If the expression INVOKE(declval(), declval()...) is well formed when treated as an unevaluated operand (Clause 5), the member typedef type shall name the type decltype(INVOKE(declval(), declval()...)); otherwise, there shall be no member type. If the given INVOKE expression is invalid, ::type should not exist. But an attempt to use it this way to detect a valid call fails. Below is a short demo program. A non-overloaded function name and a functor type with an overloaded call operator are passed to result_of through a type traits style SFINAE wrapper. None of the cases work. In 2 of the 3 cases the failure fires the static assertion, but not for the multiple overload issue. #include template< typename fn, typename = void > struct is_invokable : std::false_type {}; template< typename fn > struct is_invokable< fn, typename std::conditional< true, void, typename std::result_of< fn >::type >::type > : std::true_type {}; void f( int ); static_assert( ! is_invokable< decltype( f ) &( char const * ) >(), "can convert c-string to int" ); struct s { void operator() ( int ) {} void operator() ( float ) {} }; static_assert( ! is_invokable< s( double ) >(), "resolved ambiguous conversion" ); static_assert( ! is_invokable< s( char * ) >(), "converted pointer to number" );