Merge pull request #387 from boostorg/issue382

Correct boost_no_ctype_functions.ipp for C++20.
This commit is contained in:
jzmaddock
2021-07-07 09:44:38 +01:00
committed by GitHub

View File

@ -12,32 +12,40 @@
// macros and don't provide functions. Under C++ it's an error // macros and don't provide functions. Under C++ it's an error
// to provide the macros at all, but that's a separate issue. // to provide the macros at all, but that's a separate issue.
#include <ctype.h> #include <cctype>
namespace boost_no_ctype_functions { namespace boost_no_ctype_functions {
extern "C" {
typedef int (* character_classify_function)(int);
}
void pass_function(character_classify_function)
{
}
int test() int test()
{ {
pass_function(isalpha); using std::isalpha;
pass_function(isalnum); using std::isalnum;
pass_function(iscntrl); using std::iscntrl;
pass_function(isdigit); using std::isdigit;
pass_function(isgraph); using std::isgraph;
pass_function(islower); using std::islower;
pass_function(isprint); using std::isprint;
pass_function(ispunct); using std::ispunct;
pass_function(isspace); using std::isspace;
pass_function(isupper); using std::isupper;
pass_function(isxdigit); using std::isxdigit;
return 0;
int r = 0;
char c = 'a';
r |= (isalpha)(c);
r |= (isalnum)(c);
r |= (iscntrl)(c);
r |= (isdigit)(c);
r |= (isgraph)(c);
r |= (islower)(c);
r |= (isprint)(c);
r |= (ispunct)(c);
r |= (isspace)(c);
r |= (isupper)(c);
r |= (isxdigit)(c);
return r == 0 ? 1 : 0;
} }
} }