public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "david.irvine at maidsafe dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/56004] Possible bug with decltype and access modifer order
Date: Wed, 16 Jan 2013 18:17:00 -0000	[thread overview]
Message-ID: <bug-56004-4-E6irYB2ydK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56004-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #4 from David Irvine <david.irvine at maidsafe dot net> 2013-01-16 18:16:58 UTC ---
I see

In my case in a simpler version than posted 

this compiles fine  

template <class T>
class Synchronised {
    public:
        Synchronised(T t = T{}) : t_{t} {}
        template <typename F>
        auto operator()(F f) const -> decltype(f(t_)) {
            std::lock_guard<std::mutex> lock{mutex_};
            return f(t_);
        }
        private: // place this before public: and this object compiles
            mutable T t_;
            mutable std::mutex mutex_;
};

Fails and swapping private to be declared before public works ! as below

This will not compile 

template <class T>
class Synchronised {
      private: // place this before public: and this object compiles
            mutable T t_;
            mutable std::mutex mutex_;

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

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.


  parent reply	other threads:[~2013-01-16 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 15:13 [Bug c++/56004] New: " david.irvine at maidsafe dot net
2013-01-16 16:20 ` [Bug c++/56004] " redi at gcc dot gnu.org
2013-01-16 16:41 ` david.irvine at maidsafe dot net
2013-01-16 17:31 ` redi at gcc dot gnu.org
2013-01-16 18:17 ` david.irvine at maidsafe dot net [this message]
2013-01-16 18:26 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56004-4-E6irYB2ydK@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).