Boost logo

Boost :

From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2023-01-10 10:11:47


> On 9. Jan 2023, at 19:15, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
> It will be better if you show how the existing code (before the delayed_forward
> transformation) looks like.

I added FooOld, which corresponds to the unsafe design I want to replace.
https://godbolt.org/z/15q9EqnfP

> You could also point to the actual code in Histogram for those who would like
> even more context.

Here is the related issue.
https://github.com/boostorg/histogram/issues/379

The classes which we are discussing to improve are the axis classes. Several of these axis classes have throwing constructors. They all accept an optional Metadata in the ctor, which is user-defined and in general a non-trivial type. A comparably simple example is the integer axis.

https://github.com/boostorg/histogram/blob/develop/include/boost/histogram/axis/integer.hpp

> If I understand correctly, the lack of strong guarantee is caused by the by-value
> constructor moving from the argument even when construction fails? E.g.
>
> Foo foo( true, std::move( my_t ) );
> // leaves my_t moved-from on exception

Yes. I added some code to main in godbolt to illustrate this.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk