[Bug c++/56004] Possible bug with decltype and access modifer order

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 16 18:26:00 GMT 2013


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

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

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-16 18:25:52 UTC ---
(In reply to comment #4)
> I think you are saying the same thing but this is what I mean by private coming
> before public (changing accessors or their order). I think it is the only
> situation I have encountered this.

You still seem to have some weird mental model about public and private.

This has nothing to do with "public" or "private"

In your example t_ happens to be private, but that is completely irrelevant.

It only matters if it is declared before it is used. It can be declared public,
or declared private, or protected, it's irrelevant.

This doesn't work either, even though everything is public:

template <class T>
class Synchronised {

    public:
        Synchronised(T t = T{}) : t_{t} {}
        template <typename F>
        auto operator()(F f) const -> decltype(f(t_)) {
            return f(t_);
        }

    public:
            mutable T t_;
  };


Closing as not a bug.



More information about the Gcc-bugs mailing list