Can be used with various emplace functions to allow in-place constructing a non-movable value using a callable.
class NonMovable final {
public:
static NonMovable Make() { return NonMovable(42); }
NonMovable(NonMovable&&) = delete;
NonMovable& operator=(NonMovable&&) = delete;
int Get() const { return value_; }
private:
explicit NonMovable(int value) : value_(value) {}
int value_;
};
TEST(LazyPrvalue, Optional) {
std::optional<NonMovable> opt;
EXPECT_EQ(opt->Get(), 42);
}
Definition at line 20 of file lazy_prvalue.hpp.