This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/56004] Possible bug with decltype and access modifer order
- From: "david.irvine at maidsafe dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Jan 2013 18:16:58 +0000
- Subject: [Bug c++/56004] Possible bug with decltype and access modifer order
- Auto-submitted: auto-generated
- References: <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.