On Wed, Apr 19, 2017 at 01:33:40AM +0200, Marc Espie wrote: > On Tue, Apr 18, 2017 at 08:24:55PM +0200, Christian Weisgerber wrote: > > I tried to get boost to build with clang, but failed pretty miserably > > because I don't know what I'm doing. > > > > If anybody wants to look into this, here's what I got: > > * Configure with --with-toolset=clang > > * Fix boost_has_nl_types_h.ipp, from upstream. > > * Some haphazard changes to clang-linux.jam, patterned after those > > to gcc.jam. Likely incomplete. > > > > I got stumped at the first non-trivial problem: > > > > ./boost/type_traits/is_convertible.hpp:86:63: error: too many arguments > > provided to function-like macro invocation > > static decltype(test_aux<To1>(boost::declval<From1>()), one()) > > test(int); > > ^ > > /usr/include/c++/v1/__config:673:11: note: macro 'decltype' defined here > > # define decltype(__x) __decltype(__x) > > ^ > > > > As far as I can google, decltype(a, b) is valid, but it fails due > > to our macro. FreeBSD somehow doesn't run into this, but I don't > > know why. > > decltype is a built-in starting in C++11. > > What you have here is compatibility glue happening before C++11.
This code is somewhat crazy. The idea is to evaluate things in a way such that if it's syntactically/semantically correct, then it will be chosen. And then you do a sizeof on it to determine the result. So, decltype(test_aux<To1>(boost::declval<From1>()), one()) will actually evaluate to decltype(one()) the part before the comma is just an expr1, expr2 that evaluates to expr2 (well syntactically anyway). It's there just so to check that there are templates that do make sense wrt test_aux<To1>(boost::declval<From1>()) yeah, this is somewhat crazy. the big difference being that decltype is already present in gcc pre-C++11, since it's actually a gcc extension that eventually made it into the standard.