Avoid exponential grow of const references and rvalue references in constructor

Actually, this is the precise reason why perfect forwarding was introduced. Rewrite the constructor as template <typename L, typename O> LinearClassifier(L && loss, O && optimizer) : _loss(std::forward<L>(loss)) , _optimizer(std::forward<O>(optimizer)) {} But it will probably be much simpler to do what Ilya Popov suggests in his answer. To be honest, I usually do it this … Read more

Does a const reference class member prolong the life of a temporary?

Only local const references prolong the lifespan. The standard specifies such behavior in ยง8.5.3/5, [dcl.init.ref], the section on initializers of reference declarations. The reference in your example is bound to the constructor’s argument n, and becomes invalid when the object n is bound to goes out of scope. The lifetime extension is not transitive through … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)