December 2021
Intermediate to advanced
352 pages
9h 32m
English
constexpr for values that can be computed at compile timeconst to constexprPrior to C++11, const machinery was restricted to two things: qualifying a type as const, and thus any instance of that type as immutable, and qualifying a nonstatic member function such that *this is const in its body, like this:
class int_wrapper {
public:
explicit int_wrapper(int i);
void mutate(int i);
int inspect() const;
private:
int m_i;
};
auto const i = int_wrapper{7}; // i is of type int_wrapper const
// i.mutate(5); // Cannot invoke non-const qualified
// member function on const object
auto j = i.inspect(); // Assign from inspect
We are sure you are familiar with this. You may also be familiar with ...
Read now
Unlock full access