On 12/1/2020 4:36 PM, Kostas Savvidis via Boost wrote:
On Dec 1, 2020, at 22:05, Antony Polukhin via Boost
wrote: My alternative idea of "nice to have" is a single Boost library that can use either boost or std components in its interface. That's not always possible to obtain though.
I've tried that and it kind of works. There are still problems: * users have to use macro to customize the library * bcp still pulls in the Boost alternatives * code redability suffers from typedefs * you still kind of have two different libraries
Here is a case study. Some while ago I proposed to Steven Watanabe, the maintainer of boost.random to produce a version of my MIXMAX random number generator for inclusion. The software at that point was plain vanilla C++11.
After a go-ahead from Steven I added a series of boosticisms in order to make the stuff conform to how things were done in boost.random. The only sticky point was std:array. I was informed by Steven that the library must work with C++03 and there I had to use boost::array or something else. Not wanting to use typedefs and macros such as the below,
#ifndef BOOST_NO_CXX11_HDR_ARRAY #include <array> #define mixmaxarray std::array #else #include
#define mixmaxarray boost::array #endif ...#undef mixmaxarray The other alternative kindly proposed by Steven was: namespace boost { namespace random { namespace arrayns = std; } }
I wrote a library called cxx_dual ( https://github.com/eldiener/cxx_dual
) to solve a problem like yours, but it did not meet with general
approval. With cxx_dual your code above could have been:
#include
And yet another suggestion was to turn off inclusion of MIXMAX under C++03, but that required messing with [[config.requires cxx11_hdr_array]] in the jamfile for tests which I learned had been a source of problems back in 2016! http://boost.2283326.n4.nabble.com/question-regarding-quot-requires-cxx11-hd... http://boost.2283326.n4.nabble.com/question-regarding-quot-requires-cxx11-hd...
So, what was the least disruptive solution? Yes, going with boost::array everywhere.
That certainly works ! But then the end-user who is compiling with C++11 on up in his code and using std::array when he needs a C++ array class might be a bit piqued that he has to use boost::array in your case. OTOH if he is compiling with C++11 on up he is probably using std::random instead of boost::random so your choice is right.