Commit b0599220 authored by Kenton Varda's avatar Kenton Varda

Work around Clang bug 22354.

https://llvm.org/bugs/show_bug.cgi?id=22354

At the time DisallowConstCopy was introduced, GCC 4.7 and Clang 3.2 refused to allow the non-const copy constructors to be defaulted inline. This must have been concluded to be a compiler bug, as GCC 4.8 and Clang 3.4 seem fine with it. So, we can clean this up.

Meanwhile, the above-linked Clang bug triggered when a DisallowConstCopy derivative is captured by value in a C++14 generic lambda. capnp::CallContext in particular tended to be hit by this a lot. The bug only affects non-default (or out-of-line default) copy constructors, and thus is conveniently sidestepped by this change.
parent 497605ae
...@@ -349,16 +349,12 @@ struct DisallowConstCopy { ...@@ -349,16 +349,12 @@ struct DisallowConstCopy {
// disallow const copies. Hey, cool, that's exactly what we want. // disallow const copies. Hey, cool, that's exactly what we want.
DisallowConstCopy() = default; DisallowConstCopy() = default;
DisallowConstCopy(DisallowConstCopy&); DisallowConstCopy(DisallowConstCopy&) = default;
DisallowConstCopy(DisallowConstCopy&&) = default; DisallowConstCopy(DisallowConstCopy&&) = default;
DisallowConstCopy& operator=(DisallowConstCopy&); DisallowConstCopy& operator=(DisallowConstCopy&) = default;
DisallowConstCopy& operator=(DisallowConstCopy&&) = default; DisallowConstCopy& operator=(DisallowConstCopy&&) = default;
}; };
// Apparently these cannot be defaulted inside the class due to some obscure C++ rule.
inline DisallowConstCopy::DisallowConstCopy(DisallowConstCopy&) = default;
inline DisallowConstCopy& DisallowConstCopy::operator=(DisallowConstCopy&) = default;
template <typename T> template <typename T>
struct DisallowConstCopyIfNotConst: public DisallowConstCopy { struct DisallowConstCopyIfNotConst: public DisallowConstCopy {
// Inherit from this when implementing a template that contains a pointer to T and which should // Inherit from this when implementing a template that contains a pointer to T and which should
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment