Is it safe to make a const reference member to a temporary variable?
No, this is not safe. More precisely this is UB, means anything is possible. When you pass 123.0 + 2.0 to the constructor of Foo, a temporary double will be constructed and bound to the parameter fx. The temporary will be destroyed after the full expression (i.e. Foo p(123.0 + 2.0);), then the reference member … Read more