Skip to content

Commit

Permalink
Merge pull request #387 from boostorg/issue382
Browse files Browse the repository at this point in the history
Correct boost_no_ctype_functions.ipp for C++20.
  • Loading branch information
jzmaddock authored Jul 7, 2021
2 parents a8bdf6a + 73557f7 commit c3de80c
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions test/boost_no_ctype_functions.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,40 @@
// macros and don't provide functions. Under C++ it's an error
// to provide the macros at all, but that's a separate issue.

#include <ctype.h>
#include <cctype>

namespace boost_no_ctype_functions {

extern "C" {
typedef int (* character_classify_function)(int);
}

void pass_function(character_classify_function)
{
}

int test()
{
pass_function(isalpha);
pass_function(isalnum);
pass_function(iscntrl);
pass_function(isdigit);
pass_function(isgraph);
pass_function(islower);
pass_function(isprint);
pass_function(ispunct);
pass_function(isspace);
pass_function(isupper);
pass_function(isxdigit);
return 0;
using std::isalpha;
using std::isalnum;
using std::iscntrl;
using std::isdigit;
using std::isgraph;
using std::islower;
using std::isprint;
using std::ispunct;
using std::isspace;
using std::isupper;
using std::isxdigit;

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;
}

}
Expand Down

0 comments on commit c3de80c

Please sign in to comment.