error_code using c++11 and boost

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

error_code using c++11 and boost

Boost - Users mailing list
Hello,

A project that uses Boost 1.6X (filesystem, uuid, asio) and C++14 on multiplatform.

Does it make sense to use std::error_code in this project ? The concern is compatibility between boost and std. The filesystem_error exception will return a boost ::system::error_code which is not compatible with std::error_code as far as I can tell. Exception is not an option.

Would it be possible for boost to implement some sort of convertion method from boost::system::error_code to std::errror_code?

Thanks

kind regards, Lars







_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: error_code using c++11 and boost

Boost - Users mailing list
On 11/16/18 4:06 PM, Lars via Boost-users wrote:

> Would it be possible for boost to implement some sort of convertion
> method from boost::system::error_code to std::errror_code?

The upcoming 1.69 release of Boost.System has built-in support for
std::error_code.

If you need to use earlier versions, then you can create a bridge
between the two:

   http://breese.github.io/2016/06/18/unifying-error-codes.html
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: error_code using c++11 and boost

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On Fri, Nov 16, 2018 at 7:12 AM Lars via Boost-users <[hidden email]> wrote:
> A project that uses Boost 1.6X (filesystem, uuid, asio) and C++14 on multiplatform.
>
> Does it make sense to use std::error_code in this project ? The concern is compatibility between boost and std. The filesystem_error exception will return a boost ::system::error_code which is not compatible with std::error_code as far as I can tell. Exception is not an option.
>
> Would it be possible for boost to implement some sort of convertion method from boost::system::error_code to std::errror_code?

You could use LEAF to avoid having to translate between std::error_code and boost::error_code in the first place. See https://zajo.github.io/leaf/#technique_disparate_error_types.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: error_code using c++11 and boost

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On Fri, 16 Nov 2018 at 18:46, Bjorn Reese via Boost-users
<[hidden email]> wrote:
> The upcoming 1.69 release of Boost.System has built-in support for
> std::error_code.

I was looking into this and got really confused.
- I don't see any mention to that in
https://www.boost.org/users/history/version_1_69_0.html
- I guess it is
https://github.com/boostorg/system/commit/6010be4144ce126e79a7eee56f5b40eef8085b87,
but that has been there since 1.65

One "new" thing listed in the 1.69 release notes is "Boost.System is
now header-only". But I can see a reference to
BOOST_ERROR_CODE_HEADER_ONLY in Boost.System from 2012
(https://github.com/boostorg/system/commit/65e14ff1670ea4cf41fb31d989b31ce9d93a03af).
And Chrono documentation has been documenting the "undocumented
feature" (BOOST_ERROR_CODE_HEADER_ONLY) for a long time. Up to 1.54 it
said "but it is buggy (see #7347 duplicate symbol while
BOOST_ERROR_CODE_HEADER_ONLY is defined)", but that warning was
removed in 1.55.

So it looks like,
- Boost.System has been getting header-only for years
- Boost.Chrono has considered Boost.System header-only-ready since 1.55
- Boost.System considers itself header-only-ready since 1.69
- Boost.System has had built-in support for std::error_code since
1.65... but it has never been officially announced, so it's unclear
how good that support is, including in the upcoming 1.69.

Anybody has any more info about all this?
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: error_code using c++11 and boost

Boost - Users mailing list
On 7/12/2018 03:34, Cristian Morales Vega wrote:
> One "new" thing listed in the 1.69 release notes is "Boost.System is
> now header-only". But I can see a reference to
> BOOST_ERROR_CODE_HEADER_ONLY in Boost.System from 2012
> (https://github.com/boostorg/system/commit/65e14ff1670ea4cf41fb31d989b31ce9d93a03af).
> And Chrono documentation has been documenting the "undocumented
> feature" (BOOST_ERROR_CODE_HEADER_ONLY) for a long time. Up to 1.54 it
> said "but it is buggy (see #7347 duplicate symbol while
> BOOST_ERROR_CODE_HEADER_ONLY is defined)", but that warning was
> removed in 1.55.

BOOST_ERROR_CODE_HEADER_ONLY only worked correctly with *some* build
configurations and platforms -- notably, error categories that should
compare equal did *not* do so with some combinations of DLLs and shared
libraries.

It was not defined by default so that people have to consciously decide
to shoot themselves in the foot (or that they have tested that for their
particular application and platform it is not a problem).

In 1.69, the way that error_category comparison works has been altered
(see the new constructor mentioned in the release notes), which permits
distinct category objects to still compare equal, which means that it is
now safe to build the standard error_category objects header-only in all
cases.

What perhaps should be emphasized a bit stronger in the release notes is
that it would be a very good idea for any custom error_category objects
(especially those in libraries) to make use of these ids as well.  (It's
documented how to do that in the reference docs for the constructor.)
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: error_code using c++11 and boost

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
Ideally, the C++11 or C++14, just re-implemented the thing in boost for many years.  Either pure C++14, or boost, so easy to choose. According the experience from our real product, still stick to boost is the best.

So, to the real program, once you decided to use C++11 or C++14, you should consider always stick to it, and never mix the critical pat with boost's implementation. Back to the error code, it's best to stick one type of exception, since even the bridge would be also maintained by time.

Today's C++ standard is never solid and published carefully, its quality degenerated a lot compared to the past, so it's the best to use something real reliable and able to finish the product, spend the least time and resource to handle the useless detail, even could be resolved at the very beginning.

On Sat, Nov 17, 2018 at 12:12 AM Lars via Boost-users <[hidden email]> wrote:
Hello,

A project that uses Boost 1.6X (filesystem, uuid, asio) and C++14 on multiplatform.

Does it make sense to use std::error_code in this project ? The concern is compatibility between boost and std. The filesystem_error exception will return a boost ::system::error_code which is not compatible with std::error_code as far as I can tell. Exception is not an option.

Would it be possible for boost to implement some sort of convertion method from boost::system::error_code to std::errror_code?

Thanks

kind regards, Lars






_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users