Skip to content
Snippets Groups Projects
Commit 8a3ac30e authored by Sandipan Mohanty's avatar Sandipan Mohanty
Browse files

Fix typos and errors in constexprmem.cc

parent 7f007da5
No related branches found
No related tags found
No related merge requests found
struct Example {
int val = -1;
constexpr Example(int i)
: val { i }
{
}
constexpr Example(const Example&) = default;
constexpr ~Example() = default;
constexpr auto operator=(const Example&) -> Example& = default;
constexpr auto get() const -> int { return val; }
constexpr void set(int j) { val = j; }
};
auto main() -> int
{
constexpr Example ex { 50 };
// ex.set(42);
// set() can't work because ex is a constexpr variable
// constexpr variables are automatically const
static_assert(ex.get() == 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment