That
privateis unnecessary, the default access specifier for aclassis alreadyprivate:class number_bag { /*private*/ size_t m_size; FloatingPoint m_sum; FloatingPoint m_square_sum;Mark functions that doshould not throw
noexcept(in your case, all of them). This helps the compiler optimize if you compile with exceptions.Use
std::moveto avoid unnecessary copies:number_bag(size_t size, FloatingPoint sum, FloatingPoint square_sum) : m_size{size}, m_sum{std::move(sum)}, m_square_sum{std::move(square_sum)} {}
Mod Moved Comments To Chat
[@darhuuk](https://codereview.stackexchange.com/users/117457/darhuuk) made me realize that `std::common_type` is the wrong tool for the job.
Rakete1111
- 2.6k
- 1
- 16
- 23