Describe the bug
Passing an l-value reference to entity::set results in the move assignment operator being called instead of the copy assignment operator.
To Reproduce
Edit hello_world example:
#include <hello_world.h>
#include <iostream>
struct Length
{
double m = 0.0;
Length() {}
Length(const Length& b) :
m{b.m}
{
std::cout << "length copy constructor\n";
}
Length& operator=(const Length& b)
{
this->m = b.m;
std::cout << "length copy assignment\n";
return *this;
}
Length(Length&& b) :
m{b.m}
{
b.m = -1.0;
std::cout << "length move constructor\n";
}
Length& operator=(Length&& b)
{
this->m = b.m;
b.m = -1.0;
std::cout << "length move assignment\n";
return *this;
}
~Length() {}
};
int main(int, char *[])
{
flecs::world ecs;
Length l;
l.m = 10.0;
ecs.entity().set(l);
std::cout << "l = " << l.m << "\n";
}
Expected output
length copy assignment
l = 10
Actual output
length move assignment
l = -1
Additional context
Compiler: gcc (GCC) 14.2.1 20250207
Describe the bug
Passing an l-value reference to entity::set results in the move assignment operator being called instead of the copy assignment operator.
To Reproduce
Edit hello_world example:
Expected output
Actual output
Additional context
Compiler: gcc (GCC) 14.2.1 20250207