I've been trying to figure out why my inspector tells me "Usage of non-initialized field '_bar' when called from function 'create'" . I use a factory pattern a lot in my current project and never had this issue pop up and so I am confused if the inspector (which to my knowledge never reported false warnings so far) is wrong or am I not seeing an issue here?
Was able to reduce the issue down to this example:
struct Bar {};
class Foo
{
public:
static auto create(Bar bar) -> Foo
{
return Foo { bar };
}
private:
Bar _bar; // Usage of non-initialized field '_bar' when called from function 'create'
explicit Foo(Bar bar) : _bar(bar) {}
};
update: adding a custom move constructor removes the warning. Now I am even more confused