Re: [boost] Adding polymorphic_value to boost
Message: 10 Date: Thu, 16 Nov 2017 02:14:30 -0700 From: Jonathan Coe
To: boost@lists.boost.org Cc: Matt Calabrese Subject: [boost] Adding polymorphic_value to boost Message-ID: Content-Type: text/plain; charset="UTF-8" I'd like to propose adding the class-template `polymorphic_value` to boost.
`polymorphic_value` is designed to allow the compiler to correctly generate special member functions for classes with polymorphic components (It's `any` with an interface).
`polymorphic_value` has been proposed for standardisation in P0201 and has advanced through the Library Evolution group in Albuquerque (Nov 5-10). https://wg21.link/p0201
A working draft of the proposal and implementation can be found at https://github.com/jbcoe/polymorphic_value
I gave a presentation about polymorphic_value at C++::London here: https://skillsmatter.com/skillscasts/9539-a-polymorphic-value-type-for-c-plu...
Matt Calabrese has kindly offered to be review manager.
Kind regards,
Jon Hi, I'd be interested in such a utility. Mathias Gaunard proposed something similar on the mailing list a long while ago, I implemented a simple version myself based on that. I have a small number of questions. Given that this is a value type, does the current approach over-expose pointer (ownership) in the interface (in essence it still appears to be a glorified smart pointer) and understate its more fundamental purpose as a regular value with dynamic type? There might be other things which can usefully be added for such a value type, for example permitting direct construction of an object of specific (derived) type, by passing the type as well as the arguments for the constructor of that type (or wrapping the arguments in some kind of in-place factory with explicit type). Something like:
// Simple wrapper to enable a static type to be passed through a
forwarding constructor.
template <typename T>
struct Type {};
// Forwarding constructor - actual type is deduced from type wrapped in
(unnamed) first argument's type
template
participants (1)
-
Tom