Boost logo

Boost :

Subject: Re: [boost] Adding polymorphic_value to boost
From: Robert Ramey (ramey_at_[hidden])
Date: 2017-11-19 21:31:20

On 11/16/17 1:14 AM, Jonathan Coe via Boost wrote:
> 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).
> A working draft of the proposal and implementation can be found at
> I gave a presentation about polymorphic_value at C++::London here:
> Matt Calabrese has kindly offered to be review manager.
> Kind regards,
> Jon

I looked over the github repo and the standards proposals. I also
looked over the posts in this thread. I'm thinking the the enthusiasm
is a little premature. Just some random observations which occurred to
me as I looked this over.


 From looking at the proposed implementation and one small sentence:

"A polymorphic_value<T> may hold a an object of a class publicly derived
from T"

which suggests to me that certain operations such as assigment, copy,
operators? etc. could be used with different instances created with
different types all derived from type T. Sort of like a variant whose
underlying types is that set of types derived from T. I don't know if I
got this right - but reading the text and looking at the code, this is
the impression I get.

If I got it wrong, there are only really two possibilities:

a) I'm stupid
b) The explanation/motivation isn't rich enough.

Just for the sake of argument, let's suppose that b) is the correct one.

The motivating case seems to be usage as constituent of a composite
object. But this seems to me totally unrelated to the interesting
features of the "polymorphic value_type". I can't see why it's included
or what it shows.

So I would like to see some examples of problems that this would solve
and how it would solve them. I would also like to see summary reference
including valid expressions and type requirements on the type T parameter.

Looks OK - but I'd have to invest more effort to be sure.

Source Code
OK - I'm nit picking here. I found the extensive usage of white space
meant that I could only display about 20 lines of my code on my monitor.
I would have found less blank lines and more {} added to other lines a
big help in being able to read the code. I don't want for this to go
on a tangent which ends up at the tabs/spaces cul-de-sac. So don't feel
the need to respond to this.

Soooooooo - In my humble opinion, this submission needs more work before
it could seriously considered for review as a boost library.

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at