On 27.1.2016. 17:32, Robert Ramey wrote:
I confronted and addressed this problem in the Safe Numerics library.
The data type is called "checked_result<R>". Although it was intended to be internal to the library, I did document and test it independently. One thing that turned out to be necessary in my application was that it be constexpr.
Nice, another one ;D
I'm not entirely convinced that a general solution is desirable or even possible. It's a simple data type. But once you start using it you run into application specific issues such as should it be convertible, constexpr, etc., ... . On the other hand, if it is worthwhile, to standardize/libraryize/ etc it's going to entail a huge amount of bike sheding - as we've already had a taste of.
Given the amount of independent solutions that keep springing up "standardization/libraryization" is IMO the hopeful outcome...In my introduction to Err I start from the already existing std::error_code&co. to arrive to a new solution that is IMO better in every respect (std::error_code is after all a C++03-era tool that came a bit late to the party). So, if std::error_code was standardized so can some other tool for the same/similar purpose if it is indeed better in every respect. And the inevitable bikeshedding can/will hopefully give us a solution that is atleast adaptable enough so as to be usable even in specialized cases (e.g. like your's or Niall's) at least through some form of parametrization (if it is not reusable directly) - so long as we terminate the duplication and wheel reinvention... -- "What Huxley teaches is that in the age of advanced technology, spiritual devastation is more likely to come from an enemy with a smiling face than from one whose countenance exudes suspicion and hate." Neil Postman