C++03 / C++11 compatibility question for compiled libraries

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
129 messages Options
1234 ... 7
Reply | Threaded
Open this post in threaded view
|

C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
Dear list,

I have a technical question I do not know how to address, and I would
like to know how people deal with this.

To put things in the background: boost.test uses heavily boost::function
and boost::bind, however I would like to use in some circumstances
std::function and std::bind, which are, for instance, variadic.

Boost.test is compiled with b2. I believe if the user does not pass
additional parameters to the build, the default is to use whatever is
provided in the Jamfile, that compiles the static and shared libraries
in C++03 mode.

If the user of boost.test compiles in C++03, it is ok if the library is
used in a C++11 project. The other way is obviously not true.

Now, in the headers of boost.test, I can detect for the compiler
version, and depending on the language settings, activate an API that is
C++11.
OTOH, if I do not want users to be confused, this API should be header
only. But this hardly work in practice, as the C++03 and C++11 APIs are
usually not separable.

Say:

struct test_case {

    // compiled member function
    test_case(boost::function<void ()> function_to_test);

    #if Cpp11
    // std::function variant to ensure compatibility with std::bind
    test_case(std::function<void ()> function_to_test);
    #endif

private:
    boost::function<void ()> m_function_to_test;
};

This API is obviously not good at all, and for having the slightest
chance to make this work, the 2 APIs C++11 vs C++03 should be mutually
exclusive. This also produces 2 different incompatible shared/static
libraries, which is even more confusing for the user as the compiler
options should be transitively passed to the user's code, or the user
should be aware of which library to link with.

So, the questions are:
* how do other boost developers deal with this?
* what is your experience on users in terms of compilation+linking? are
usually people aware of this problem and they compile in C++11 all the
code including boost?
* is there any better option? All the other options I see are even worse.

Thanks,
Raffi


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 02/08/18 11:50, Raffi Enficiaud via Boost wrote:

>
> Say:
>
> struct test_case {
>
>      // compiled member function
>      test_case(boost::function<void ()> function_to_test);
>
>      #if Cpp11
>      // std::function variant to ensure compatibility with std::bind
>      test_case(std::function<void ()> function_to_test);
>      #endif

boost::function should already be compatible with std::bind.

> private:
>      boost::function<void ()> m_function_to_test;
> };
>
> This API is obviously not good at all, and for having the slightest
> chance to make this work, the 2 APIs C++11 vs C++03 should be mutually
> exclusive. This also produces 2 different incompatible shared/static
> libraries, which is even more confusing for the user as the compiler
> options should be transitively passed to the user's code, or the user
> should be aware of which library to link with.
>
> So, the questions are:
> * how do other boost developers deal with this?

In Boost.Log, I maintain linking ABI always compatible with C++03. For
example, I convert rvalue references to lvalue references in the header
and call a special internal function from the library that assumes move
semantics.

The same is possible with library components, although it may incur more
overhead. In case of boost/std::function, I would use boost::function or
even a custom function wrapper internally (the latter is useful to
remove the dependency on Boost.Function). I don't see any advantage of
using std::function.

> * what is your experience on users in terms of compilation+linking? are
> usually people aware of this problem and they compile in C++11 all the
> code including boost?

There is a large class of use cases where the user links against Boost
that is built by someone else. In Linux, it is typical to rely on the
Boost version shipped with distro. On Windows, I presume, some users
prefer our pre-built binaries. So the use case when the headers and the
library are used with different C++ version settings are real and a good
library should account for that.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 2/8/2018 3:50 AM, Raffi Enficiaud via Boost wrote:

> Dear list,
>
> I have a technical question I do not know how to address, and I would
> like to know how people deal with this.
>
> To put things in the background: boost.test uses heavily boost::function
> and boost::bind, however I would like to use in some circumstances
> std::function and std::bind, which are, for instance, variadic.
>
> Boost.test is compiled with b2. I believe if the user does not pass
> additional parameters to the build, the default is to use whatever is
> provided in the Jamfile, that compiles the static and shared libraries
> in C++03 mode.
>
> If the user of boost.test compiles in C++03, it is ok if the library is
> used in a C++11 project. The other way is obviously not true.
>
> Now, in the headers of boost.test, I can detect for the compiler
> version, and depending on the language settings, activate an API that is
> C++11.
> OTOH, if I do not want users to be confused, this API should be header
> only. But this hardly work in practice, as the C++03 and C++11 APIs are
> usually not separable.
>
> Say:
>
> struct test_case {
>
>      // compiled member function
>      test_case(boost::function<void ()> function_to_test);
>
>      #if Cpp11
>      // std::function variant to ensure compatibility with std::bind
>      test_case(std::function<void ()> function_to_test);
>      #endif
>
> private:
>      boost::function<void ()> m_function_to_test;
> };
>
> This API is obviously not good at all, and for having the slightest
> chance to make this work, the 2 APIs C++11 vs C++03 should be mutually
> exclusive. This also produces 2 different incompatible shared/static
> libraries, which is even more confusing for the user as the compiler
> options should be transitively passed to the user's code, or the user
> should be aware of which library to link with.
>
> So, the questions are:
> * how do other boost developers deal with this?
> * what is your experience on users in terms of compilation+linking? are
> usually people aware of this problem and they compile in C++11 all the
> code including boost?
> * is there any better option? All the other options I see are even worse.

As far as which library to use, depending on the compiler/version
available, either boost or std, of two very similar libraries, this is
what my Cxx_dual library (https://github.com/eldiener/cxx_dual) is all
about. But others did not like it preferring instead to roll their own
solution or more simply to use Boost at all times because it is
available. I naturally prefer my own solution but of course I am biased.

>
> Thanks,
> Raffi


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
Edward Diener wrote:

> As far as which library to use, depending on the compiler/version
> available, either boost or std, of two very similar libraries, this is
> what my Cxx_dual library (https://github.com/eldiener/cxx_dual) is all
> about.

That's not going to work at all if link compatibility is desired. If you
have

class something
{
private:

    CXXD::function<void()> f_;

public:

    // ...
};

the layout of `something` changes between C++03 and C++11, which leads to
incredibly nasty things at runtime as objects appear at the wrong address
and the observed behavior makes no sense.

I inadvertently introduced such a problem in Boost.System when I made the
object layout dependent on whether <system_error> was available, to enable
conversions from/to std::error_code. It's not fun at all. (I have since
fixed that, and added tests that link to the library from a forced-03 or
forced-11 main.cpp. Incidentally, the layout of std::string also changes
between 03 and 11, so if such compatibility is desired, you can't use that
either.)

(But there's absolutely no need to use std::function "for std::bind
compatibility". boost::function can store std::bind just fine (and vice
versa.))


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 8 February 2018 at 03:20, Andrey Semashev via Boost <
[hidden email]> wrote:

> The same is possible with library components, although it may incur more
> overhead. In case of boost/std::function, I would use boost::function or
> even a custom function wrapper internally (the latter is useful to remove
> the dependency on Boost.Function). I don't see any advantage of using
> std::function.
>

Using std::function has one advantage, though, it's standardised.

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 02/08/18 17:27, degski via Boost wrote:

> On 8 February 2018 at 03:20, Andrey Semashev via Boost <
> [hidden email]> wrote:
>
>> The same is possible with library components, although it may incur more
>> overhead. In case of boost/std::function, I would use boost::function or
>> even a custom function wrapper internally (the latter is useful to remove
>> the dependency on Boost.Function). I don't see any advantage of using
>> std::function.
>
> Using std::function has one advantage, though, it's standardised.

In the context of this discussion, it's irrelevant.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 2/8/2018 9:20 AM, Peter Dimov via Boost wrote:

> Edward Diener wrote:
>
>> As far as which library to use, depending on the compiler/version
>> available, either boost or std, of two very similar libraries, this is
>> what my Cxx_dual library (https://github.com/eldiener/cxx_dual) is all
>> about.
>
> That's not going to work at all if link compatibility is desired. If you
> have
>
> class something
> {
> private:
>
>     CXXD::function<void()> f_;
>
> public:
>
>     // ...
> };
>
> the layout of `something` changes between C++03 and C++11, which leads
> to incredibly nasty things at runtime as objects appear at the wrong
> address and the observed behavior makes no sense.

I discuss a solution for this in the documentation topic "Use in a
non-header only library".

>
> I inadvertently introduced such a problem in Boost.System when I made
> the object layout dependent on whether <system_error> was available, to
> enable conversions from/to std::error_code. It's not fun at all. (I have
> since fixed that, and added tests that link to the library from a
> forced-03 or forced-11 main.cpp. Incidentally, the layout of std::string
> also changes between 03 and 11, so if such compatibility is desired, you
> can't use that either.)
>
> (But there's absolutely no need to use std::function "for std::bind
> compatibility". boost::function can store std::bind just fine (and vice
> versa.))


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
Edward Diener wrote:

> I discuss a solution for this in the documentation topic "Use in a
> non-header only library".

lib MyLib : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_std : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_fn_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_fn_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_fn : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_ar_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_ar : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_fn_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_fn_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_fn_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_fn : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
lib MyLib_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
<define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
lib MyLib_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
<define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
<define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;

This probably gives you an idea why one might prefer to always use the Boost
components instead.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 2/8/2018 10:48 AM, Peter Dimov via Boost wrote:

> Edward Diener wrote:
>
>> I discuss a solution for this in the documentation topic "Use in a
>> non-header only library".
>
> lib MyLib : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_std : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_fn_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_fn_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_fn : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_ar : MyHeader.cpp : <define>CXXD_ARRAY_USE_STD
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_fn_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_fn_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_fn_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_fn : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_STD <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_rx_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
> lib MyLib_rx : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_STD
> <define>CXXD_TUPLE_USE_BOOST <define>MYLIB_BEING_BUILT ;
> lib MyLib_tp : MyHeader.cpp : <define>CXXD_ARRAY_USE_BOOST
> <define>CXXD_FUNCTION_USE_BOOST <define>CXXD_REGEX_USE_BOOST
> <define>CXXD_TUPLE_USE_STD <define>MYLIB_BEING_BUILT ;
>
> This probably gives you an idea why one might prefer to always use the
> Boost components instead.

As discussed in the doc to the CXX Dual library you do not have to
choose to allow all possible variations, depending on how many different
CXXD mods you decide to use. You could decide that if C++11 on up is
being used your name is some 'xxx_std' while if C++11 on up is not being
used your name is 'xxx', and therefore you have two naming variants. Of
course this assumes your non-header only library only supports compilers
which in C++11 mode on up offers C++11 libraries for what you are using
in your library. But how many modern compilers do not support C++11
libraries properly in C++11 mode on up, and would you really want to
support such libraries that do not.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
Edward Diener wrote:

> As discussed in the doc to the CXX Dual library you do not have to choose
> to allow all possible variations, depending on how many different CXXD
> mods you decide to use. You could decide that if C++11 on up is being used
> your name is some 'xxx_std' while if C++11 on up is not being used your
> name is 'xxx', and therefore you have two naming variants.

You could do that, and it simplifies things considerably (although it
doesn't allow you to link 03 with 11.)

But if you do that, what's the point of having separate CXXD macros per
component then? You only need one, and the whole CXXD library collapses to a
single `namespace cxxd = std|boost` directive.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 8 February 2018 at 09:16, Andrey Semashev via Boost <
[hidden email]> wrote:

> On 02/08/18 17:27, degski via Boost wrote:
>
>> On 8 February 2018 at 03:20, Andrey Semashev via Boost <
>> [hidden email]> wrote:
>>
>> The same is possible with library components, although it may incur more
>>> overhead. In case of boost/std::function, I would use boost::function or
>>> even a custom function wrapper internally (the latter is useful to remove
>>> the dependency on Boost.Function). I don't see any advantage of using
>>> std::function.
>>>
>>
>> Using std::function has one advantage, though, it's standardised.
>>
>
> In the context of this discussion, it's irrelevant.


 It seems only logical to me to decrease coupling with other boost
libraries as time moves on, to use the std-equivalent of certain boost
libraries... Subtle differences exist (between std- and boost-versions of
certain libs), i.e. random, file-system and others... and this is a pita...
IMHO, boost libs that state that they are let's say C++14, should use
std::array, std::chrono, std::random (and std::function), etc... and
decrease coupling with other parts of boost...

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
degski wrote:
> >> Using std::function has one advantage, though, it's standardised.
> >>
> >
> > In the context of this discussion, it's irrelevant.
>
>  It seems only logical to me to decrease coupling with other boost
> libraries as time moves on, to use the std-equivalent of certain boost
> libraries...

This discussion is about link compatibility between code compiled with C++03
and code compiled with C++11. If your code uses std::function, it can't be
compiled with C++03 and therefore this thread is simply not for you.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 8 February 2018 at 13:25, Peter Dimov via Boost <[hidden email]>
wrote:

> degski wrote:
>
>> >> Using std::function has one advantage, though, it's standardised.
>> >>
>> >
>> > In the context of this discussion, it's irrelevant.
>>
>>  It seems only logical to me to decrease coupling with other boost
>> libraries as time moves on, to use the std-equivalent of certain boost
>> libraries...
>>
>
> This discussion is about link compatibility between code compiled with
> C++03 and code compiled with C++11. If your code uses std::function, it
> can't be compiled with C++03 and therefore this thread is simply not for
> you.


Yes, I get that, I'm stating the opposite, if it's compiled with C++11, it
should use std::function.

There's an interesting std::function replacement in Cometa
<https://github.com/kfrlib/cometa>, btw.

degski

PS: I really don't understand the focus of boost to always want to compile
stuff with the most archaic compilers possible. If your using an old
compiler, just use a(n older) boost version that works with that specific
compiler.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 2/8/2018 12:21 PM, Peter Dimov via Boost wrote:

> Edward Diener wrote:
>
>> As discussed in the doc to the CXX Dual library you do not have to
>> choose to allow all possible variations, depending on how many
>> different CXXD mods you decide to use. You could decide that if C++11
>> on up is being used your name is some 'xxx_std' while if C++11 on up
>> is not being used your name is 'xxx', and therefore you have two
>> naming variants.
>
> You could do that, and it simplifies things considerably (although it
> doesn't allow you to link 03 with 11.)
>
> But if you do that, what's the point of having separate CXXD macros per
> component then? You only need one, and the whole CXXD library collapses
> to a single `namespace cxxd = std|boost` directive.

Because most libraries are header-only. Because assuming that if a
single CXXD mod xxx is std, all others are std is not what I would call
good programming.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 02/08/18 22:36, degski via Boost wrote:

> On 8 February 2018 at 13:25, Peter Dimov via Boost <[hidden email]>
> wrote:
>
>> degski wrote:
>>
>>>>> Using std::function has one advantage, though, it's standardised.
>>>>>
>>>>
>>>> In the context of this discussion, it's irrelevant.
>>>
>>>   It seems only logical to me to decrease coupling with other boost
>>> libraries as time moves on, to use the std-equivalent of certain boost
>>> libraries...
>>>
>>
>> This discussion is about link compatibility between code compiled with
>> C++03 and code compiled with C++11. If your code uses std::function, it
>> can't be compiled with C++03 and therefore this thread is simply not for
>> you.
>
>
> Yes, I get that, I'm stating the opposite, if it's compiled with C++11, it
> should use std::function.

How does that solve the linking incompatibility problem?

> PS: I really don't understand the focus of boost to always want to compile
> stuff with the most archaic compilers possible. If your using an old
> compiler, just use a(n older) boost version that works with that specific
> compiler.

It's not just about older compilers. There are code bases that are not
compatible with C++11, some of them using Boost. Given that the default
in recent compilers is C++14, those code bases explicitly set C++03.
Those code bases are supposed to link with whatever Boost version
(which, of course, is compiled in the default C++14 mode) that is
shipped by your distro.

On older systems there is a reverse problem, when the system-supplied
Boost is compiled in C++03 and you want to compile your code in C++11 or
later.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 8 February 2018 at 13:54, Andrey Semashev via Boost <
[hidden email]> wrote:

> ... Those code bases are supposed to link with whatever Boost version


Why does this have to be the case, why does it "have" to be whatever
version?

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 02/08/18 23:23, degski via Boost wrote:
> On 8 February 2018 at 13:54, Andrey Semashev via Boost <
> [hidden email]> wrote:
>
>> ... Those code bases are supposed to link with whatever Boost version
>
>
> Why does this have to be the case, why does it "have" to be whatever
> version?

Because otherwise such code base becomes unshippable with that distro
(i.e. cannot be packaged for that distro). This includes both preparing
the package for the distro, if you're the package maintainer from the
distro, and public users' repositories (e.g. PPAs).

If you're distributing software separately from the distro ecosystem,
you have to build and package Boost yourself, which may in turn require
re-packaging other components that depend on Boost or can be used with
your software. This quickly increases the packaging burden on you.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
degski wrote:

> PS: I really don't understand the focus of boost to always want to compile
> stuff with the most archaic compilers possible. If your using an old
> compiler, just use a(n older) boost version that works with that specific
> compiler.

So mp11 and Beast need to be C++17 because those using C++11 can always use
an earlier version of Boost.

Except earlier versions of Boost have neither. Oops.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
On 8 February 2018 at 15:06, Peter Dimov via Boost <[hidden email]>
wrote:

> So mp11 and Beast need to be C++17 because those using C++11 can always
> use an earlier version of Boost.


No, no, no, f.e. boost::mp11, or boost::beast are to be compiled with C++11
and should therefor use std C++11 libraries instead of their equivalent
boost version... (as boost::mp11 does, as far as I've seen, but you're far
better placed to say something about that than me, I would say).

Boost-1.66 source code plus the stuff that is generated building boost
(just x64, debug, release) occupies very close to 5GB of disk-space, time
to start cutting that down.

But if your using gcc-3.3, clang-3.6 or vs2012, one cannot expect boost
-1.67 to compile with it. On windows, I would say this is more of an issue
as on linux, as you'd be obliged to use/install old crt's, that are known
to have (publicized) vulnerabilities...

I have an issue with boost looking backwards all the time. Clang and VC
(we've got (experimentally) concepts!) both seem to have (nowadays) adopted
very much a forward looking view, to be ahead of the standard. I would like
boost to do the same. I'm talking about std::random (boost version
deviates), std::chrono (not sure whether boost version deviates),
std::file_system (boost version deviates), etc...

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: C++03 / C++11 compatibility question for compiled libraries

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
On 8 February 2018 at 14:42, Andrey Semashev via Boost <
[hidden email]> wrote:

> Because otherwise such code base becomes unshippable with that distro
> (i.e. cannot be packaged for that distro).


Not everybody uses linux, in reality most people don't...

degski

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
1234 ... 7