Skip to content

Instantly share code, notes, and snippets.

@emfomenk
Last active March 13, 2018 16:28
Show Gist options
  • Save emfomenk/c6d21cc85e9904d44f2a49bf98b0c02f to your computer and use it in GitHub Desktop.
Save emfomenk/c6d21cc85e9904d44f2a49bf98b0c02f to your computer and use it in GitHub Desktop.
Strange behavior of g++ w/ concepts
#include <stdio.h>
#include <vector>
#define D(v) printf("[%s:%d] %d\n", __PRETTY_FUNCTION__, __LINE__, v)
#if STRANGE_CONCEPTS
template <typename Src, typename Dst>
concept bool VectorSource()
{ return true; }
template <typename T = double >
class MeuTVector
{
template < VectorSource<MeuTVector> X>
MeuTVector &operator=(const X &x)
{ return *this; }
};
#endif
struct A {
int v;
A(int v): v(v) {}
A(const A& a) { v = a.v; D(v); }
private:
A(const A&& a) { v = a.v; D(v); }
// A(const A&& a) = delete; // the fix
};
struct B: public A {
using A::A;
};
int main() {
std::vector<B> vec;
vec.push_back(B(1));
return 0;
}
@emfomenk
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment