Subject: [boost] compact_optional -- prompting interest
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2015-09-25 10:35:53
I would like to inquire if there would be an interest in Boost in another
library for storing optional objects, but working under different design
Compact optional T has (or can have) the same sizeof as T. It uses one
indicated value of T to represent the "empty" (or "singular") value. You
can declare it like this:
compact_optional<evp_int<int, -1>> oi;
This reads: we have an optional int, with type int inside, where -1
represents the empty value. It can never have a genuine (non-empty value
-1). This can be used, for instance, to wrap the std::string::npos into:
With the same memory layout as std::string::size_type, but with the special
syntax for managing the singular value.
It is not meant to be an alternative to Boost.Optional: it targets a
different application space.
The (single-header) implementation is at:
The documentation is at:
For the motivation and design rationale see this article:
Any feedback is welcome.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk