Hey, I have two classes I've developed that have been used in my own
projects that I think could have a place in Boost. They are outlined below.
readonly<T>:
This is a wrapper class for a type to replace a const-type field in a
movable class. It has const access to the type so can't modify except for
the move constructor and move assignment operator.
This solves the problem that no fields in a movable class can be const
which can cloud the intentions of a field.
readonly copies the accessor patterns seen in classes such as optional and
the smart pointer collection.
Example:
struct foo
{
foo() : str("hello world") {}
readonlystd::string str;
};
foo f;
auto g = std::move(f);
static_assert(std::is_move_constructible<foo>{}, "");
std::cout << *g.str << std::endl;
g.str->clear() // error: non-const method.
-----
newtype