Hi, I'm trying to integrate beast into my project witch uses concepts. But when I tried to compile it, it burried me in errors. So I just tried to compile one of the examples which was closest to my usecase but that doesn't compile either. Is that a bug or is it intended that way? In the latter case: what would I have to change in the example to make it work?
BOOST_BEAST_VERSION 277
gcc version 9.2.1 20200123 (Debian 9.2.1-25)
error log: https://gist.github.com/jed1/555abce54f87fd20acfaf2e56749cf1d
Hi @jed1, thanks for reporting this and sorry for the delayed response.
I can confirm that I have replicated the bug and am now investigating:
a) whether it's a coding error or a compiler bug
b) whether there is a fix or workaround.
I'll keep you posted.
OK, it turns out to be a little more interesting that just a compiler/code bug.
I've tracked down the problem, and it's actually in the Boost.Asio library on which we depend.
In Concepts.TS, the syntax for writing a concept was : concept bool ConceptName = Criteria;
However, in c++20 the accepted syntax is: concept ConceptName = Critera;. i.e. the bool is implied and you must not spell it out.
Clang accepts both forms of the syntax (but should utter a warning if it sees concept bool), but GCC's implementation came much later and is based on the accepted c++20 spec.
There is also a further problem that the method for constraining concepts has evolved since Concepts.TS (but I am by no means an expert on this).
The recommended workaround (answer offered by Barry Revzin in the page above) is:
#if __cpp_concepts >= 201707
// working paper, C++20 concepts
#define CONCEPT concept
#else
// TS
#define CONCEPT concept bool
#endif
template <typename T>
CONCEPT C = true;
Unfortunately this doesn't help us because of the following lines in boost/asio/detail/config.hpp:348:
// Support concepts on compilers known to allow them.
#if !defined(BOOST_ASIO_HAS_CONCEPTS)
# if !defined(BOOST_ASIO_DISABLE_CONCEPTS)
# if __cpp_concepts
# define BOOST_ASIO_HAS_CONCEPTS 1
# define BOOST_ASIO_CONCEPT concept bool // <<==== HERE
# endif // __cpp_concepts
# endif // !defined(BOOST_ASIO_DISABLE_CONCEPTS)
#endif // !defined(BOOST_ASIO_HAS_CONCEPTS)
At the present time, the only non-invasive solution is to disable concepts in compilation units that involve Asio (which will presumably be the majority of them in your program) when you compile with gcc.
Modify the ASIO source code as detailed in boostorg/asio#312 - see this comment
Sorry I can't be of more help.
Great news. Chris has indicated that a fix has been committed to master branch of asio and will be included in the next Boost release.
https://github.com/chriskohlhoff/asio/commit/00157db09efc9ce65e01ea37346a06b3d82d4f65
I can confirm that Boost-1.73 solved this issue, no workaround needed
Most helpful comment
Great news. Chris has indicated that a fix has been committed to master branch of asio and will be included in the next Boost release.
https://github.com/chriskohlhoff/asio/commit/00157db09efc9ce65e01ea37346a06b3d82d4f65