Last active
March 13, 2018 16:28
-
-
Save emfomenk/c6d21cc85e9904d44f2a49bf98b0c02f to your computer and use it in GitHub Desktop.
Strange behavior of g++ w/ concepts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What?