public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables
@ 2013-05-15  8:52 record.nctu.cis91 at gmail dot com
  2013-05-15  9:38 ` [Bug libstdc++/57283] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: record.nctu.cis91 at gmail dot com @ 2013-05-15  8:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57283

            Bug ID: 57283
           Summary: missing typedefs in specialized std::mem_fn for member
                    variables
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: record.nctu.cis91 at gmail dot com

Created attachment 30118
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30118&action=edit
code-reproduce-this-issue.cpp

I found that gcc complain that "no type named ‘argument_type’ in ‘class
std::_Mem_fn<int cls::*>’", with the code in attachment.

Then I try to locate the problem and find there is no any typedefs for
argument_type.
So I guess it's missing the required typedefs.
>From gcc-bugs-return-422300-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed May 15 09:12:55 2013
Return-Path: <gcc-bugs-return-422300-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 13711 invoked by alias); 15 May 2013 09:12:54 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 13665 invoked by uid 48); 15 May 2013 09:12:50 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/57276] Waste work in cgraph_edge_brings_all_agg_vals_for_node()
Date: Wed, 15 May 2013 09:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed
Message-ID: <bug-57276-4-33d8a1SYEb@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57276-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57276-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-05/txt/msg00973.txt.bz2
Content-length: 558

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW276

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-05-15
                 CC|                            |jamborm at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/57283] missing typedefs in specialized std::mem_fn for member variables
  2013-05-15  8:52 [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables record.nctu.cis91 at gmail dot com
@ 2013-05-15  9:38 ` redi at gcc dot gnu.org
  2013-05-15 11:42 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-15  9:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57283

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The standard is clear, the typedef is not required when wrapping a pointer to
member data, see [func.memfn]

You can use a lambda expression in C++11:

    [](const cls& c) { return !c.value; };

In C++14 you will be able to write a generic lambda to negate arbitrary
function objects, replacing std::not1 completely:

    [](auto f) { return !f(); };


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/57283] missing typedefs in specialized std::mem_fn for member variables
  2013-05-15  8:52 [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables record.nctu.cis91 at gmail dot com
  2013-05-15  9:38 ` [Bug libstdc++/57283] " redi at gcc dot gnu.org
@ 2013-05-15 11:42 ` redi at gcc dot gnu.org
  2013-05-15 12:11 ` redi at gcc dot gnu.org
  2013-05-16 13:33 ` record.nctu.cis91 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-15 11:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57283

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Lin Yi-Li from comment #2)
> Sorry I missed that 'pm is a pointer to member function...'.
> 
> I know that C++11 has lambda, but using std::mem_fn is sometimes much clear.

You can still use std::mem_fn, the problem is with std::not1, which only works
with the C++98 function object protocol.

> But according to standard, value from std::mem_fn for variable will not be
> able to work with std::not1. Even if the usage is similiar to the one for
> member function takes no argument.

It's similar but not the same, for a member function the result_type is the
return type and the argument_type is dictated by the cv-qualifiers of the
member function, i.e. for a const member function the argument_type is 'const
T*', but for a member variable the result_type depends on whether you call it
with a const or non-const argument.

Should mem_fn(&cls::value) have result_type=int& and argument_type=cls*
or result_type=const int& and argument_type=const cls*?
The result of mem_fn(&cls::value) is polymorphic.

> So is it possible to be an enhancement?

It might be possible to generalize std::unary_negate, but that's for the
standard committee not GCC's bugzilla.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/57283] missing typedefs in specialized std::mem_fn for member variables
  2013-05-15  8:52 [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables record.nctu.cis91 at gmail dot com
  2013-05-15  9:38 ` [Bug libstdc++/57283] " redi at gcc dot gnu.org
  2013-05-15 11:42 ` redi at gcc dot gnu.org
@ 2013-05-15 12:11 ` redi at gcc dot gnu.org
  2013-05-16 13:33 ` record.nctu.cis91 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-15 12:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57283

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
N.B. you can also do it with a nested std::bind expression and std::logical_not

std::bind(std::logical_not<int>(),
          std::bind(std::mem_fn(&cls::value), std::placeholders::_1))

in C++14 that means you can provide a working not1 replacement:

template<typename F>
auto not1(F f)
{
    return std::bind(std::logical_not<>(), std::bind(f,
std::placeholders::_1));
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/57283] missing typedefs in specialized std::mem_fn for member variables
  2013-05-15  8:52 [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables record.nctu.cis91 at gmail dot com
                   ` (2 preceding siblings ...)
  2013-05-15 12:11 ` redi at gcc dot gnu.org
@ 2013-05-16 13:33 ` record.nctu.cis91 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: record.nctu.cis91 at gmail dot com @ 2013-05-16 13:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57283

--- Comment #5 from Lin Yi-Li <record.nctu.cis91 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> N.B. you can also do it with a nested std::bind expression and
> std::logical_not
> 
> std::bind(std::logical_not<int>(),
>           std::bind(std::mem_fn(&cls::value), std::placeholders::_1))
> 
> in C++14 that means you can provide a working not1 replacement:
> 
> template<typename F>
> auto not1(F f)
> {
>     return std::bind(std::logical_not<>(), std::bind(f,
> std::placeholders::_1));
> }

I understand the problem of std::mem_fn + member variable now.
Thank you for your explanation.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-16 13:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-15  8:52 [Bug libstdc++/57283] New: missing typedefs in specialized std::mem_fn for member variables record.nctu.cis91 at gmail dot com
2013-05-15  9:38 ` [Bug libstdc++/57283] " redi at gcc dot gnu.org
2013-05-15 11:42 ` redi at gcc dot gnu.org
2013-05-15 12:11 ` redi at gcc dot gnu.org
2013-05-16 13:33 ` record.nctu.cis91 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).