-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef BOOST_DESCRIBE_DETAIL_PP_UTILITIES_HPP_INCLUDED | ||
#define BOOST_DESCRIBE_DETAIL_PP_UTILITIES_HPP_INCLUDED | ||
|
||
// Copyright 2021 Peter Dimov | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#define BOOST_DESCRIBE_PP_EXPAND(x) x | ||
|
||
#define BOOST_DESCRIBE_PP_CAT(x, y) BOOST_DESCRIBE_PP_CAT_I(x, y) | ||
#define BOOST_DESCRIBE_PP_CAT_I(x, ...) x ## __VA_ARGS__ | ||
|
||
#if defined(_MSC_VER) && !defined(__clang__) | ||
|
||
#define BOOST_DESCRIBE_PP_FIRST(x) BOOST_DESCRIBE_PP_FIRST_I((x)) | ||
#define BOOST_DESCRIBE_PP_FIRST_I(x) BOOST_DESCRIBE_PP_FIRST_II x | ||
#define BOOST_DESCRIBE_PP_FIRST_II(x, ...) x | ||
|
||
#else | ||
|
||
#define BOOST_DESCRIBE_PP_FIRST(x) BOOST_DESCRIBE_PP_FIRST_I(x) | ||
#define BOOST_DESCRIBE_PP_FIRST_I(x, ...) x | ||
|
||
#endif | ||
|
||
#define BOOST_DESCRIBE_PP_IS_PAREN_I(x) BOOST_DESCRIBE_PP_CAT(BOOST_DESCRIBE_PP_IS_PAREN_I_, BOOST_DESCRIBE_PP_IS_PAREN_II x) | ||
#define BOOST_DESCRIBE_PP_IS_PAREN_II(...) 0 | ||
#define BOOST_DESCRIBE_PP_IS_PAREN_I_0 1, | ||
#define BOOST_DESCRIBE_PP_IS_PAREN_I_BOOST_DESCRIBE_PP_IS_PAREN_II 0, | ||
|
||
#define BOOST_DESCRIBE_PP_IS_PAREN(x) BOOST_DESCRIBE_PP_FIRST(BOOST_DESCRIBE_PP_IS_PAREN_I(x)) | ||
|
||
#define BOOST_DESCRIBE_PP_EMPTY | ||
|
||
#define BOOST_DESCRIBE_PP_IS_EMPTY(x) BOOST_DESCRIBE_PP_IS_EMPTY_I(BOOST_DESCRIBE_PP_IS_PAREN(x), BOOST_DESCRIBE_PP_IS_PAREN(x BOOST_DESCRIBE_PP_EMPTY ())) | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_I(x, y) BOOST_DESCRIBE_PP_IS_EMPTY_II(x, y) | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_II(x, y) BOOST_DESCRIBE_PP_IS_EMPTY_III(x, y) | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_III(x, y) BOOST_DESCRIBE_PP_IS_EMPTY_III_ ## x ## y | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_III_00 0 | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_III_01 1 | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_III_10 0 | ||
#define BOOST_DESCRIBE_PP_IS_EMPTY_III_11 0 | ||
|
||
#define BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_CAT(BOOST_DESCRIBE_PP_CALL_I_, BOOST_DESCRIBE_PP_IS_EMPTY(x))(F, a, x) | ||
#define BOOST_DESCRIBE_PP_CALL_I_0(F, a, x) F(a, x) | ||
#define BOOST_DESCRIBE_PP_CALL_I_1(F, a, x) | ||
|
||
#endif // #ifndef BOOST_DESCRIBE_DETAIL_PP_UTILITIES_HPP_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2021 Peter Dimov | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/describe/detail/pp_utilities.hpp> | ||
#include <boost/describe/detail/config.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
|
||
#if !defined(BOOST_DESCRIBE_CXX11) | ||
|
||
#include <boost/config/pragma_message.hpp> | ||
|
||
BOOST_PRAGMA_MESSAGE("Skipping test because C++11 is not available") | ||
int main() {} | ||
|
||
#else | ||
|
||
#define S(x) S2(x) | ||
#define S2(x) S3(x) | ||
#define S3(x) #x | ||
|
||
#define F(a, x) (a, x) | ||
|
||
#if defined(_MSC_VER) | ||
# pragma warning(disable: 4003) // not enough arguments for macro invocation | ||
#endif | ||
|
||
char const * s1 = S(BOOST_DESCRIBE_PP_CALL(F, a, x)); | ||
char const * s2 = "" S(BOOST_DESCRIBE_PP_CALL(F, a, )); | ||
char const * s3 = S(BOOST_DESCRIBE_PP_CALL(F, a, () x)); | ||
char const * s4 = S(BOOST_DESCRIBE_PP_CALL(F, a, (b, c) x)); | ||
|
||
int main() | ||
{ | ||
BOOST_TEST_CSTR_EQ( s1, "(a, x)" ); | ||
BOOST_TEST_CSTR_EQ( s2, "" ); | ||
BOOST_TEST_CSTR_EQ( s3, "(a, () x)" ); | ||
BOOST_TEST_CSTR_EQ( s4, "(a, (b, c) x)" ); | ||
|
||
return boost::report_errors(); | ||
} | ||
|
||
#endif // !defined(BOOST_DESCRIBE_CXX11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2021 Peter Dimov | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/describe/detail/pp_utilities.hpp> | ||
#include <boost/describe/detail/config.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
|
||
#if !defined(BOOST_DESCRIBE_CXX11) | ||
|
||
#include <boost/config/pragma_message.hpp> | ||
|
||
BOOST_PRAGMA_MESSAGE("Skipping test because C++11 is not available") | ||
int main() {} | ||
|
||
#else | ||
|
||
#define S(x) S2(x) | ||
#define S2(x) #x | ||
|
||
#if defined(_MSC_VER) | ||
# pragma warning(disable: 4003) // not enough arguments for macro invocation | ||
#endif | ||
|
||
char const * s1 = S(BOOST_DESCRIBE_PP_IS_EMPTY()); | ||
char const * s2 = S(BOOST_DESCRIBE_PP_IS_EMPTY(x)); | ||
char const * s3 = S(BOOST_DESCRIBE_PP_IS_EMPTY(() x)); | ||
char const * s4 = S(BOOST_DESCRIBE_PP_IS_EMPTY((a, b) x)); | ||
|
||
int main() | ||
{ | ||
BOOST_TEST_CSTR_EQ( s1, "1" ); | ||
BOOST_TEST_CSTR_EQ( s2, "0" ); | ||
BOOST_TEST_CSTR_EQ( s3, "0" ); | ||
BOOST_TEST_CSTR_EQ( s4, "0" ); | ||
|
||
return boost::report_errors(); | ||
} | ||
|
||
#endif // !defined(BOOST_DESCRIBE_CXX11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021 Peter Dimov | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/describe/detail/pp_utilities.hpp> | ||
#include <boost/describe/detail/config.hpp> | ||
#include <boost/core/lightweight_test.hpp> | ||
|
||
#if !defined(BOOST_DESCRIBE_CXX11) | ||
|
||
#include <boost/config/pragma_message.hpp> | ||
|
||
BOOST_PRAGMA_MESSAGE("Skipping test because C++11 is not available") | ||
int main() {} | ||
|
||
#else | ||
|
||
#define S(x) S2(x) | ||
#define S2(x) S3(x) | ||
#define S3(x) #x | ||
|
||
#if defined(_MSC_VER) | ||
# pragma warning(disable: 4003) // not enough arguments for macro invocation | ||
#endif | ||
|
||
char const * s1 = S(BOOST_DESCRIBE_PP_IS_PAREN()); | ||
char const * s2 = S(BOOST_DESCRIBE_PP_IS_PAREN(x)); | ||
char const * s3 = S(BOOST_DESCRIBE_PP_IS_PAREN(() x)); | ||
char const * s4 = S(BOOST_DESCRIBE_PP_IS_PAREN((a, b) x)); | ||
|
||
int main() | ||
{ | ||
BOOST_TEST_CSTR_EQ( s1, "0" ); | ||
BOOST_TEST_CSTR_EQ( s2, "0" ); | ||
BOOST_TEST_CSTR_EQ( s3, "1" ); | ||
BOOST_TEST_CSTR_EQ( s4, "1" ); | ||
|
||
return boost::report_errors(); | ||
} | ||
|
||
#endif // !defined(BOOST_DESCRIBE_CXX11) |