fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

uniform_int_distribution<char> does not compile with libc++ #91

Closed arrowd closed 7 months ago

arrowd commented 7 months ago

With Clang and libc++ 16.0.6 I get:

In file included from /wrkdirs/usr/ports/net/libsockpp/work/sockpp-0.8.1/examples/unix/unechotest.cpp:39:
In file included from /usr/include/c++/v1/iostream:43:
In file included from /usr/include/c++/v1/ios:221:
In file included from /usr/include/c++/v1/__locale:18:
In file included from /usr/include/c++/v1/mutex:192:
In file included from /usr/include/c++/v1/__mutex_base:20:
In file included from /usr/include/c++/v1/system_error:154:
In file included from /usr/include/c++/v1/string:576:
In file included from /usr/include/c++/v1/string_view:1025:
In file included from /usr/include/c++/v1/algorithm:1848:
In file included from /usr/include/c++/v1/__algorithm/ranges_sample.h:13:
In file included from /usr/include/c++/v1/__algorithm/sample.h:18:
/usr/include/c++/v1/__random/uniform_int_distribution.h:157:5: error: static assertion failed due to requirement '__libcpp_random_is_valid_inttype<char>::value': IntType must be a supported integer type
    static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/net/libsockpp/work/sockpp-0.8.1/examples/unix/unechotest.cpp:83:36: note: in instantiation of template class 'std::uniform_int_distribution<char>' requested here
    uniform_int_distribution<char> dist(0, 25);
                                   ^
fpagliughi commented 7 months ago

This sounds familiar…

fpagliughi commented 7 months ago

There it is... someone posted this a few years ago as a problem on Windows with MSVC 2015 (#42), and when I tried it with a later version of MSVC, it worked for me. So I assumed it was a Microsoft thing.

But looking at the class definition, apparently std::uniform_int_distribution<T> is only defined for T as a short, int, long, or long long (signed or unsigned).

[edit] Oh, and apparently I already knew this, when that same person sent in a PR (#43) to fix it... but just for the examples that compile on Windows! Forgot it was also in the example(s) for UNIX-domain sockets.

fpagliughi commented 7 months ago

Fixed in v0.8.2