mirror of
https://github.com/boostorg/describe.git
synced 2026-01-20 16:32:36 +00:00
Compare commits
29 Commits
feature/pp
...
feature/ov
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ca49a6af2 | ||
|
|
1bf6dddac0 | ||
|
|
39cf63cee1 | ||
|
|
5ebca2615a | ||
|
|
7f36a2c798 | ||
|
|
564f849629 | ||
|
|
ed26d4c495 | ||
|
|
8aa347b171 | ||
|
|
acf14803ba | ||
|
|
ffb6787d28 | ||
|
|
e15c09c848 | ||
|
|
c9f780cbfb | ||
|
|
ae5c3c862f | ||
|
|
c6fa6f125e | ||
|
|
e503b32c51 | ||
|
|
ee415d4001 | ||
|
|
b1e0566668 | ||
|
|
f251e6f320 | ||
|
|
70eadd17a7 | ||
|
|
02cdf8734f | ||
|
|
6f8e4c879b | ||
|
|
f76971d52c | ||
|
|
fe26439f39 | ||
|
|
a876e619b7 | ||
|
|
19bb4254bc | ||
|
|
109bb07163 | ||
|
|
39c438eb08 | ||
|
|
ae31a5142f | ||
|
|
bcb70cea2c |
54
.travis.yml
54
.travis.yml
@@ -22,7 +22,7 @@ matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc CXXSTD=14-gnu,1z-gnu
|
||||
env: TOOLSET=gcc CXXSTD=14,14-gnu,1z,1z-gnu
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -32,7 +32,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc CXXSTD=14-gnu,1z-gnu
|
||||
env: TOOLSET=gcc CXXSTD=14,14-gnu,1z,1z-gnu
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -42,7 +42,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc CXXSTD=14-gnu,17-gnu
|
||||
env: TOOLSET=gcc CXXSTD=14,14-gnu,17,17-gnu
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -143,6 +143,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
addons:
|
||||
@@ -153,6 +154,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang CXXSTD=14,17
|
||||
addons:
|
||||
@@ -163,6 +165,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang CXXSTD=14,17,2a
|
||||
addons:
|
||||
@@ -171,9 +174,10 @@ matrix:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
- llvm-toolchain-bionic-7
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang CXXSTD=14,17,2a
|
||||
addons:
|
||||
@@ -182,10 +186,10 @@ matrix:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
- llvm-toolchain-bionic-8
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang CXXSTD=14,17,2a
|
||||
addons:
|
||||
@@ -194,11 +198,11 @@ matrix:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang CXXSTD=14,17,2a
|
||||
addons:
|
||||
@@ -207,13 +211,39 @@ matrix:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
dist: bionic
|
||||
compiler: clang++-11
|
||||
env: TOOLSET=clang CXXSTD=14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-12
|
||||
env: UBSAN=1 TOOLSET=clang CXXSTD=14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-12
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
env: UBSAN=1 TOOLSET=clang CXXSTD=14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -221,7 +251,7 @@ matrix:
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
|
||||
|
||||
install:
|
||||
|
||||
@@ -7,8 +7,7 @@ and usage examples.
|
||||
|
||||
## Supported Compilers
|
||||
|
||||
* GCC 5 or later with `-std=gnu++14` or above
|
||||
* GCC 8 or later with `-std=c++14` or above
|
||||
* GCC 5 or later with `-std=c++14` or above
|
||||
* Clang 3.6 or later with `-std=c++14` or above
|
||||
* Visual Studio 2015, 2017, 2019
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ Peter Dimov
|
||||
:toclevels: 4
|
||||
:idprefix:
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
# Describing Class Types
|
||||
:idprefix: classes_
|
||||
|
||||
## Class Types with Public Members
|
||||
|
||||
If you have a `struct`
|
||||
|
||||
```
|
||||
@@ -31,8 +33,15 @@ It takes three arguments: the `struct` name, a list of base classes
|
||||
(empty in our example), and a list of (public) members by name (this includes
|
||||
both data members and member functions.)
|
||||
|
||||
To describe a class type with protected or private members, use the
|
||||
`BOOST_DESCRIBE_CLASS` macro instead, placing it _inside the class_.
|
||||
Since `BOOST_DESCRIBE_STRUCT` is placed outside the type, it's non-intrisive,
|
||||
does not require access to the definition, and can therefore be used to describe
|
||||
third-party types or types defined in system headers.
|
||||
|
||||
## Class Types with Protected or Private Members
|
||||
|
||||
To describe a class type, use the `BOOST_DESCRIBE_CLASS` macro instead, placing
|
||||
it _inside the class_. This gives the macro access to the protected and private
|
||||
members, but is intrusive and requires access to the definition.
|
||||
|
||||
```
|
||||
class Y: private X
|
||||
@@ -73,17 +82,11 @@ These primitives are defined in namespace `boost::describe`, in the headers
|
||||
presence of `mod_public` includes the public bases in the result, its absence
|
||||
excludes them. The other two modifiers work similarly.
|
||||
|
||||
(At least in principle. The current implementation cannot distinguish between
|
||||
protected and private base classes, so protected bases are returned as private.
|
||||
Consequently, using `mod_protected` gives no result. Lifting this limitation
|
||||
would require compiler support.)
|
||||
|
||||
`describe_members` takes a bitwise-or combination of the following possible
|
||||
modifiers: `mod_public`, `mod_protected`, `mod_private`, `mod_static`,
|
||||
`mod_function`, `mod_inherited`, `mod_hidden`.
|
||||
|
||||
The access modifiers work the same as with `describe_bases` (except here
|
||||
`mod_protected` actually works when `BOOST_DESCRIBE_CLASS` is used.)
|
||||
The access modifiers work the same as with `describe_bases`.
|
||||
|
||||
(For types annotated with `BOOST_DESCRIBE_STRUCT`, the protected and private
|
||||
member lists will be empty.)
|
||||
@@ -127,3 +130,55 @@ For an example of how to use the base and data member descriptors, see
|
||||
|
||||
For an example of how to use member function descriptors, see
|
||||
<<example_json_rpc>>.
|
||||
|
||||
## Overloaded Member Functions
|
||||
|
||||
To describe an overloaded member function, you will need to resort to
|
||||
a more complicated syntax, as simply listing its name (say, `f`) will make
|
||||
the library attempt to form a member pointer with `&X::f`, which would fail
|
||||
because it's not clear to which `f` this expression refers.
|
||||
|
||||
To disambiguate, precede the function name with the type of the function, in
|
||||
parentheses, as shown in the following example:
|
||||
|
||||
```
|
||||
struct X
|
||||
{
|
||||
int f();
|
||||
int f() const;
|
||||
void f( int x );
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_STRUCT(X, (), (
|
||||
(int ()) f,
|
||||
(int () const) f,
|
||||
(void (int)) f
|
||||
))
|
||||
```
|
||||
|
||||
The type of the function is the same as its declaration, without the name.
|
||||
|
||||
Be sure to retain the space between the parenthesized function type and its name,
|
||||
because omitting it will compile happily on GCC and Clang but will lead to
|
||||
inscrutable errors on MSVC due to its nonstandard preprocessor.
|
||||
|
||||
Pay attention to the proper placement of the parentheses, because a mistake there
|
||||
will also lead to hard to decipher compiler errors, on all compilers.
|
||||
|
||||
The same technique also works with `BOOST_DESCRIBE_CLASS`, and with static member
|
||||
functions:
|
||||
|
||||
```
|
||||
class Y
|
||||
{
|
||||
public:
|
||||
|
||||
static void f( int x );
|
||||
static void f( int x, int y );
|
||||
|
||||
BOOST_DESCRIBE_CLASS(Y, (), ((void (int)) f, (void (int, int)) f), (), ())
|
||||
};
|
||||
```
|
||||
|
||||
The case where a member function and a static member function have the same name
|
||||
and the same function type is currently not supported.
|
||||
|
||||
@@ -28,8 +28,6 @@ BOOST_DESCRIBE_ENUM(E, v1, v2, v3)
|
||||
The macro is defined in `<boost/describe/enum.hpp>` and should be placed in
|
||||
the same namespace as the enum.
|
||||
|
||||
For scoped enums, use `BOOST_DESCRIBE_ENUM_CLASS` instead.
|
||||
|
||||
If your enumerators don't have initializers, instead of repeating them
|
||||
|
||||
```
|
||||
|
||||
@@ -14,8 +14,7 @@ https://boost.org/libs/mp11[Boost.Mp11].
|
||||
|
||||
## Supported Compilers
|
||||
|
||||
* GCC 5 or later with `-std=gnu++14` or above
|
||||
* GCC 8 or later with `-std=c++14` or above
|
||||
* GCC 5 or later with `-std=c++14` or above
|
||||
* Clang 3.6 or later with `-std=c++14` or above
|
||||
* Visual Studio 2015, 2017, 2019
|
||||
|
||||
@@ -26,10 +25,13 @@ https://ci.appveyor.com/project/pdimov/describe[Appveyor].
|
||||
|
||||
This implementation has the following limitations:
|
||||
|
||||
* Up to 52 elements are supported in the lists of enumerators,
|
||||
bases, and members.
|
||||
* Protected base classes cannot be distinguished from private
|
||||
base classes and are considered private.
|
||||
* Overloaded member functions are not supported. Member names
|
||||
must be unique within the class.
|
||||
* Bitfields are not supported.
|
||||
base classes when the described class is final, and are considered
|
||||
private.
|
||||
* Bitfields are not supported. It's not possible to form a pointer
|
||||
to member to a bitfield.
|
||||
* Reference members are not supported. It's not possible to form a
|
||||
pointer to member to a reference.
|
||||
* Anonymous unions are not supported.
|
||||
* Reference members are not supported.
|
||||
|
||||
@@ -48,12 +48,6 @@ struct Di
|
||||
```
|
||||
where `vi` is the corresponding identifier passed to the macro.
|
||||
|
||||
### BOOST_DESCRIBE_ENUM_CLASS
|
||||
|
||||
`BOOST_DESCRIBE_ENUM_CLASS(E, v1, ..., vN)` should be used instead of
|
||||
`BOOST_DESCRIBE_ENUM` when `E` is a scoped enumeration type, and has
|
||||
the same effect.
|
||||
|
||||
### BOOST_DEFINE_ENUM
|
||||
|
||||
`BOOST_DEFINE_ENUM(E, v1, v2, ..., vN)` is a convenience macro expanding to
|
||||
@@ -67,7 +61,7 @@ BOOST_DESCRIBE_ENUM(E, v1, v2, ..., vN)
|
||||
`BOOST_DEFINE_ENUM_CLASS(E, v1, v2, ..., vN)` is a convenience macro expanding to
|
||||
```
|
||||
enum class E { v1, v2, ..., vN };
|
||||
BOOST_DESCRIBE_ENUM_CLASS(E, v1, v2, ..., vN)
|
||||
BOOST_DESCRIBE_ENUM(E, v1, v2, ..., vN)
|
||||
```
|
||||
|
||||
### BOOST_DEFINE_FIXED_ENUM
|
||||
@@ -83,7 +77,7 @@ BOOST_DESCRIBE_ENUM(E, v1, v2, ..., vN)
|
||||
`BOOST_DEFINE_FIXED_ENUM_CLASS(E, Base, v1, v2, ..., vN)` is a convenience macro expanding to
|
||||
```
|
||||
enum class E: Base { v1, v2, ..., vN };
|
||||
BOOST_DESCRIBE_ENUM_CLASS(E, v1, v2, ..., vN)
|
||||
BOOST_DESCRIBE_ENUM(E, v1, v2, ..., vN)
|
||||
```
|
||||
|
||||
## <boost/describe/enumerators.hpp>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ namespace describe
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> using _describe_bases = decltype( _base_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_bases = decltype( boost_base_descriptor_fn( static_cast<T*>(0) ) );
|
||||
|
||||
template<unsigned M> struct base_filter
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/modifiers.hpp>
|
||||
#include <boost/describe/detail/compute_base_modifiers.hpp>
|
||||
#include <boost/describe/detail/pp_for_each.hpp>
|
||||
#include <boost/describe/detail/list.hpp>
|
||||
#include <type_traits>
|
||||
@@ -17,29 +17,13 @@ namespace describe
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// is_public_base_of
|
||||
template<class T, class U> using is_public_base_of = std::is_convertible<U*, T*>;
|
||||
|
||||
// is_virtual_base_of
|
||||
template<class T, class U, class = void> struct can_cast: std::false_type {};
|
||||
template<class T, class U> struct can_cast<T, U, decltype((void)(U*)(T*)0)>: std::true_type {};
|
||||
|
||||
template<class T, class U> using is_virtual_base_of =
|
||||
std::integral_constant<bool, can_cast<U, T>::value && !can_cast<T, U>::value>;
|
||||
|
||||
// base_modifiers
|
||||
template<class C, class B> constexpr unsigned base_modifiers() noexcept
|
||||
{
|
||||
return (is_public_base_of<B, C>::value? mod_public: mod_private) | (is_virtual_base_of<B, C>::value? mod_virtual: 0);
|
||||
}
|
||||
|
||||
// base_descriptor
|
||||
template<class C, class B> struct base_descriptor
|
||||
{
|
||||
static_assert( std::is_base_of<B, C>::value, "A type listed as a base is not one" );
|
||||
|
||||
using type = B;
|
||||
static constexpr unsigned modifiers = base_modifiers<C, B>();
|
||||
static constexpr unsigned modifiers = compute_base_modifiers<C, B>();
|
||||
};
|
||||
|
||||
template<class C, class B> constexpr unsigned base_descriptor<C, B>::modifiers;
|
||||
@@ -53,12 +37,12 @@ template<class... T> auto base_descriptor_fn_impl( int, T... )
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto _base_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, __VA_ARGS__) ); }
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto _base_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, ##__VA_ARGS__) ); }
|
||||
|
||||
#endif
|
||||
|
||||
73
include/boost/describe/detail/compute_base_modifiers.hpp
Normal file
73
include/boost/describe/detail/compute_base_modifiers.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED
|
||||
#define BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED
|
||||
|
||||
// Copyright 2020, 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/modifiers.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace describe
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4594) // can never be instantiated - indirect virtual base class is inaccessible
|
||||
# pragma warning(disable: 4624) // destructor was implicitly defined as deleted
|
||||
#endif
|
||||
|
||||
// is_public_base_of
|
||||
|
||||
template<class T, class U> using is_public_base_of = std::is_convertible<U*, T*>;
|
||||
|
||||
// is_protected_base_of
|
||||
|
||||
struct ipb_final
|
||||
{
|
||||
template<class T, class U> using fn = std::false_type;
|
||||
};
|
||||
|
||||
struct ipb_non_final
|
||||
{
|
||||
template<class T, class U> struct fn: U
|
||||
{
|
||||
static std::true_type f( T* );
|
||||
|
||||
template<class X> static auto g( X x ) -> decltype( f(x) );
|
||||
static std::false_type g( ... );
|
||||
|
||||
using type = decltype( g((U*)0) );
|
||||
};
|
||||
};
|
||||
|
||||
template<class T, class U> using is_protected_base_of =
|
||||
typename std::conditional<std::is_final<U>::value || std::is_union<U>::value, ipb_final, ipb_non_final>::type::template fn<T, U>::type;
|
||||
|
||||
// is_virtual_base_of
|
||||
|
||||
template<class T, class U, class = void> struct can_cast: std::false_type {};
|
||||
template<class T, class U> struct can_cast<T, U, decltype((void)(U*)(T*)0)>: std::true_type {};
|
||||
|
||||
template<class T, class U> using is_virtual_base_of =
|
||||
std::integral_constant<bool, can_cast<U, T>::value && !can_cast<T, U>::value>;
|
||||
|
||||
// compute_base_modifiers
|
||||
template<class C, class B> constexpr unsigned compute_base_modifiers() noexcept
|
||||
{
|
||||
return (is_public_base_of<B, C>::value? mod_public: (is_protected_base_of<B, C>::value? mod_protected: mod_private)) | (is_virtual_base_of<B, C>::value? mod_virtual: 0);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace describe
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED
|
||||
@@ -21,11 +21,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_DESCRIBE_CXX14) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 5 && __GNUC__ <= 7 && defined(__STRICT_ANSI__)
|
||||
// g++ 5..7 with -std=c++14 doesn't support the variadic extension we need, use -std=gnu++14
|
||||
# undef BOOST_DESCRIBE_CXX14
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_DESCRIBE_CXX11)
|
||||
# define BOOST_DESCRIBE_CONSTEXPR_OR_CONST constexpr
|
||||
#else
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <boost/describe/modifiers.hpp>
|
||||
#include <boost/describe/detail/pp_for_each.hpp>
|
||||
#include <boost/describe/detail/pp_utilities.hpp>
|
||||
#include <boost/describe/detail/list.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -43,30 +44,33 @@ template<unsigned M, class... T> auto member_descriptor_fn_impl( int, T... )
|
||||
return list<member_descriptor<T, M>...>();
|
||||
}
|
||||
|
||||
#define BOOST_DESCRIBE_MEMBER_IMPL(C, m) , []{ struct D { \
|
||||
static constexpr auto pointer() noexcept { return &C::m; } \
|
||||
static constexpr auto name() noexcept { return #m; } }; return D(); }()
|
||||
template<class C, class F> constexpr auto mfn( F C::* p ) { return p; }
|
||||
template<class C, class F> constexpr auto mfn( F * p ) { return p; }
|
||||
|
||||
#define BOOST_DESCRIBE_MEMBER_IMPL(C, m) , []{ struct _boost_desc { \
|
||||
static constexpr auto pointer() noexcept { return BOOST_DESCRIBE_PP_POINTER(C, m); } \
|
||||
static constexpr auto name() noexcept { return BOOST_DESCRIBE_PP_NAME(m); } }; return _boost_desc(); }()
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto _public_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_public>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
|
||||
|
||||
#define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto _protected_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_protected>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
|
||||
|
||||
#define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto _private_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_private>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto _public_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_public>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
|
||||
|
||||
#define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto _protected_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_protected>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
|
||||
|
||||
#define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto _private_member_descriptor_fn( C * ) \
|
||||
#define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C * ) \
|
||||
{ return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_private>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,66 +5,66 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_DESCRIBE_PP_EXPAND(x) x
|
||||
#include <boost/describe/detail/pp_utilities.hpp>
|
||||
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_0(F, a)
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_1(F, a, x) F(a, x)
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_2(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_1(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_3(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_2(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_4(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_3(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_5(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_4(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_6(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_5(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_7(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_6(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_8(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_7(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_9(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_8(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_10(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_9(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_11(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_10(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_12(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_11(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_13(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_12(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_14(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_13(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_15(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_14(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_16(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_15(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_17(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_16(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_18(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_17(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_19(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_18(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_20(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_19(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_21(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_20(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_22(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_21(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_23(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_22(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_24(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_23(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_25(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_24(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_26(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_25(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_27(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_26(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_28(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_27(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_29(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_28(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_30(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_29(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_31(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_30(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_32(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_31(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_33(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_32(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_34(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_33(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_35(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_34(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_36(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_35(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_37(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_36(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_38(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_37(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_39(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_38(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_40(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_39(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_41(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_40(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_42(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_41(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_43(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_42(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_44(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_43(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_45(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_44(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_46(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_45(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_47(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_46(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_48(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_47(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_49(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_48(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_50(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_49(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_51(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_50(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_52(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(F(a, x) BOOST_DESCRIBE_PP_FOR_EACH_51(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_1(F, a, x) BOOST_DESCRIBE_PP_CALL(F, a, x)
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_2(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_1(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_3(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_2(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_4(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_3(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_5(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_4(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_6(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_5(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_7(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_6(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_8(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_7(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_9(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_8(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_10(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_9(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_11(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_10(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_12(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_11(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_13(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_12(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_14(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_13(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_15(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_14(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_16(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_15(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_17(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_16(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_18(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_17(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_19(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_18(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_20(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_19(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_21(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_20(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_22(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_21(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_23(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_22(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_24(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_23(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_25(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_24(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_26(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_25(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_27(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_26(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_28(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_27(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_29(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_28(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_30(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_29(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_31(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_30(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_32(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_31(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_33(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_32(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_34(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_33(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_35(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_34(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_36(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_35(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_37(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_36(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_38(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_37(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_39(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_38(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_40(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_39(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_41(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_40(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_42(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_41(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_43(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_42(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_44(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_43(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_45(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_44(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_46(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_45(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_47(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_46(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_48(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_47(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_49(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_48(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_50(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_49(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_51(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_50(F, a, __VA_ARGS__))
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH_52(F, a, x, ...) BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_CALL(F, a, x) BOOST_DESCRIBE_PP_FOR_EACH_51(F, a, __VA_ARGS__))
|
||||
|
||||
#define BOOST_DESCRIBE_PP_EXTRACT(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, V, ...) V
|
||||
#define BOOST_DESCRIBE_PP_FE_EXTRACT(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, V, ...) V
|
||||
|
||||
#define BOOST_DESCRIBE_PP_FOR_EACH(F, ...) \
|
||||
BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_EXTRACT(__VA_ARGS__, \
|
||||
BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_EXPAND(BOOST_DESCRIBE_PP_FE_EXTRACT(__VA_ARGS__, \
|
||||
BOOST_DESCRIBE_PP_FOR_EACH_52, \
|
||||
BOOST_DESCRIBE_PP_FOR_EACH_51, \
|
||||
BOOST_DESCRIBE_PP_FOR_EACH_50, \
|
||||
|
||||
92
include/boost/describe/detail/pp_utilities.hpp
Normal file
92
include/boost/describe/detail/pp_utilities.hpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#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)
|
||||
|
||||
#define BOOST_DESCRIBE_PP_PARSE(x) BOOST_DESCRIBE_PP_CAT(BOOST_DESCRIBE_PP_PARSE_I_, BOOST_DESCRIBE_PP_PARSE_II x)
|
||||
#define BOOST_DESCRIBE_PP_PARSE_II(...) 0, (__VA_ARGS__),
|
||||
#define BOOST_DESCRIBE_PP_PARSE_I_BOOST_DESCRIBE_PP_PARSE_II 0, ~,
|
||||
#define BOOST_DESCRIBE_PP_PARSE_I_0 1
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DESCRIBE_PP_NAME(x) BOOST_DESCRIBE_PP_NAME_I(BOOST_DESCRIBE_PP_PARSE(x))
|
||||
#define BOOST_DESCRIBE_PP_NAME_I(x) BOOST_DESCRIBE_PP_NAME_II((x))
|
||||
#define BOOST_DESCRIBE_PP_NAME_II(x) BOOST_DESCRIBE_PP_NAME_III x
|
||||
#define BOOST_DESCRIBE_PP_NAME_III(x, y, z) #z
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_PP_NAME(x) BOOST_DESCRIBE_PP_NAME_I(BOOST_DESCRIBE_PP_PARSE(x))
|
||||
#define BOOST_DESCRIBE_PP_NAME_I(x) BOOST_DESCRIBE_PP_NAME_II(x)
|
||||
#define BOOST_DESCRIBE_PP_NAME_II(x, y, z) #z
|
||||
|
||||
#endif
|
||||
|
||||
// template<class C, class F> constexpr auto mfn( F C::* p ) { return p; }
|
||||
// template<class C, class F> constexpr auto mfn( F * p ) { return p; }
|
||||
|
||||
#define BOOST_DESCRIBE_PP_POINTER(C, x) BOOST_DESCRIBE_PP_POINTER_I(C, BOOST_DESCRIBE_PP_PARSE(x))
|
||||
|
||||
#define BOOST_DESCRIBE_PP_EXPAND_V(...) __VA_ARGS__
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DESCRIBE_PP_POINTER_I(C, x) BOOST_DESCRIBE_PP_POINTER_II((C, x))
|
||||
#define BOOST_DESCRIBE_PP_POINTER_II(x) BOOST_DESCRIBE_PP_POINTER_III x
|
||||
#define BOOST_DESCRIBE_PP_POINTER_III(C, x, y, z) BOOST_DESCRIBE_PP_POINTER_III_##x(C, y, z)
|
||||
#define BOOST_DESCRIBE_PP_POINTER_III_0(C, y, z) &C::z
|
||||
#define BOOST_DESCRIBE_PP_POINTER_III_1(C, y, z) ::boost::describe::detail::mfn<C, BOOST_DESCRIBE_PP_EXPAND_V y>(&C::z)
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_PP_POINTER_I(C, x) BOOST_DESCRIBE_PP_POINTER_II(C, x)
|
||||
#define BOOST_DESCRIBE_PP_POINTER_II(C, x, y, z) BOOST_DESCRIBE_PP_POINTER_III_##x(C, y, z)
|
||||
#define BOOST_DESCRIBE_PP_POINTER_III_0(C, y, z) &C::z
|
||||
#define BOOST_DESCRIBE_PP_POINTER_III_1(C, y, z) ::boost::describe::detail::mfn<C, BOOST_DESCRIBE_PP_EXPAND_V y>(&C::z)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_DESCRIBE_DETAIL_PP_UTILITIES_HPP_INCLUDED
|
||||
@@ -12,7 +12,6 @@
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM(E, ...)
|
||||
#define BOOST_DESCRIBE_ENUM_CLASS(E, ...)
|
||||
|
||||
#else
|
||||
|
||||
@@ -39,31 +38,55 @@ template<class... T> auto enum_descriptor_fn_impl( int, T... )
|
||||
return list<enum_descriptor<T>...>();
|
||||
}
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_IMPL(E, e) , []{ struct D { \
|
||||
static constexpr auto value() noexcept { return e; } \
|
||||
static constexpr auto name() noexcept { return #e; } }; return D(); }()
|
||||
#define BOOST_DESCRIBE_ENUM_BEGIN(E) \
|
||||
inline auto boost_enum_descriptor_fn( E* ) \
|
||||
{ return boost::describe::detail::enum_descriptor_fn_impl( 0
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_CLASS_IMPL(E, e) , []{ struct D { \
|
||||
#define BOOST_DESCRIBE_ENUM_ENTRY(E, e) , []{ struct _boost_desc { \
|
||||
static constexpr auto value() noexcept { return E::e; } \
|
||||
static constexpr auto name() noexcept { return #e; } }; return D(); }()
|
||||
static constexpr auto name() noexcept { return #e; } }; return _boost_desc(); }()
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_END(E) ); }
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM(E, ...) inline auto _enum_descriptor_fn( E* ) \
|
||||
{ return boost::describe::detail::enum_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_IMPL, E, __VA_ARGS__) ); }
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM_CLASS(E, ...) inline auto _enum_descriptor_fn( E* ) \
|
||||
{ return boost::describe::detail::enum_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_CLASS_IMPL, E, __VA_ARGS__) ); }
|
||||
#define BOOST_DESCRIBE_ENUM(E, ...) \
|
||||
BOOST_DESCRIBE_ENUM_BEGIN(E) \
|
||||
BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_ENTRY, E, __VA_ARGS__) \
|
||||
BOOST_DESCRIBE_ENUM_END(E)
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_ENUM(E, ...) \
|
||||
BOOST_DESCRIBE_ENUM_BEGIN(E) \
|
||||
BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_ENTRY, E, ##__VA_ARGS__) \
|
||||
BOOST_DESCRIBE_ENUM_END(E)
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace describe
|
||||
} // namespace boost
|
||||
|
||||
#endif // defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#define BOOST_DEFINE_ENUM(E, ...) enum E { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, __VA_ARGS__)
|
||||
#define BOOST_DEFINE_ENUM_CLASS(E, ...) enum class E { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM_CLASS(E, __VA_ARGS__)
|
||||
#define BOOST_DEFINE_ENUM_CLASS(E, ...) enum class E { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, __VA_ARGS__)
|
||||
|
||||
#define BOOST_DEFINE_FIXED_ENUM(E, Base, ...) enum E: Base { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, __VA_ARGS__)
|
||||
#define BOOST_DEFINE_FIXED_ENUM_CLASS(E, Base, ...) enum class E: Base { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM_CLASS(E, __VA_ARGS__)
|
||||
#define BOOST_DEFINE_FIXED_ENUM_CLASS(E, Base, ...) enum class E: Base { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DEFINE_ENUM(E, ...) enum E { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, ##__VA_ARGS__)
|
||||
#define BOOST_DEFINE_ENUM_CLASS(E, ...) enum class E { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, ##__VA_ARGS__)
|
||||
|
||||
#define BOOST_DEFINE_FIXED_ENUM(E, Base, ...) enum E: Base { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, ##__VA_ARGS__)
|
||||
#define BOOST_DEFINE_FIXED_ENUM_CLASS(E, Base, ...) enum class E: Base { __VA_ARGS__ }; BOOST_DESCRIBE_ENUM(E, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_DESCRIBE_ENUM_HPP_INCLUDED
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace boost
|
||||
namespace describe
|
||||
{
|
||||
|
||||
template<class E> using describe_enumerators = decltype( _enum_descriptor_fn( static_cast<E*>(0) ) );
|
||||
template<class E> using describe_enumerators = decltype( boost_enum_descriptor_fn( static_cast<E*>(0) ) );
|
||||
|
||||
} // namespace describe
|
||||
} // namespace boost
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace detail
|
||||
|
||||
// _describe_members<T>
|
||||
|
||||
template<class T> using _describe_public_members = decltype( _public_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_protected_members = decltype( _protected_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_private_members = decltype( _private_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_public_members = decltype( boost_public_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_protected_members = decltype( boost_protected_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
template<class T> using _describe_private_members = decltype( boost_private_member_descriptor_fn( static_cast<T*>(0) ) );
|
||||
|
||||
template<class T> using _describe_members = mp11::mp_append<_describe_public_members<T>, _describe_protected_members<T>, _describe_private_members<T>>;
|
||||
|
||||
|
||||
26
test/Jamfile
26
test/Jamfile
@@ -15,9 +15,20 @@ project : requirements
|
||||
run quick.cpp ;
|
||||
|
||||
run pp_for_each_test.cpp ;
|
||||
run pp_is_paren_test.cpp ;
|
||||
run pp_is_empty_test.cpp ;
|
||||
run pp_call_test.cpp ;
|
||||
run pp_parse_test.cpp ;
|
||||
run pp_name_test.cpp ;
|
||||
run pp_pointer_test.cpp ;
|
||||
|
||||
run enumerators_test.cpp ;
|
||||
run empty_enum_test.cpp ;
|
||||
run trailing_comma_test.cpp ;
|
||||
|
||||
run compute_base_modifiers.cpp ;
|
||||
run bases_test.cpp ;
|
||||
|
||||
run members_test.cpp ;
|
||||
run members_test2.cpp ;
|
||||
run members_test3.cpp ;
|
||||
@@ -25,18 +36,25 @@ run members_test4.cpp ;
|
||||
run members_test5.cpp ;
|
||||
run members_test6.cpp ;
|
||||
run members_test7.cpp : : : <toolset>msvc-14.0:<build>no ;
|
||||
run overloaded_test.cpp ;
|
||||
run overloaded_test2.cpp ;
|
||||
|
||||
compile test_d_type.cpp ;
|
||||
|
||||
obj describe_cxx14 : describe_cxx14.cpp ;
|
||||
explicit describe_cxx14 ;
|
||||
|
||||
local CXX14 = [ check-target-builds describe_cxx14 describe_cxx14 : : <build>no ] ;
|
||||
|
||||
local JSON = <library>/boost//json/<warnings>off "<toolset>msvc-14.0:<build>no" ;
|
||||
local SERIALIZATION = <library>/boost//serialization/<warnings>off "-<toolset>clang:<warnings-as-errors>on" ;
|
||||
|
||||
run ../example/printing_enums_ct.cpp : : : $(CXX14) ;
|
||||
run ../example/printing_enums_rt.cpp : : : $(CXX14) ;
|
||||
run ../example/enum_to_string.cpp : : : $(CXX14) ;
|
||||
run ../example/string_to_enum.cpp : : : $(CXX14) ;
|
||||
run ../example/print_function.cpp : : : $(CXX14) ;
|
||||
run ../example/to_json.cpp /boost//json : : : $(CXX14) <toolset>msvc-14.0:<build>no ;
|
||||
run ../example/from_json.cpp /boost//json : : : $(CXX14) <toolset>msvc-14.0:<build>no ;
|
||||
run ../example/serialization.cpp /boost//serialization/<warnings>off : : : $(CXX14) "-<toolset>clang:<warnings-as-errors>on" ;
|
||||
run ../example/json_rpc.cpp /boost//json : : : $(CXX14) <toolset>msvc-14.0:<build>no ;
|
||||
run ../example/to_json.cpp : : : $(CXX14) $(JSON) ;
|
||||
run ../example/from_json.cpp : : : $(CXX14) $(JSON) ;
|
||||
run ../example/serialization.cpp : : : $(CXX14) $(SERIALIZATION) ;
|
||||
run ../example/json_rpc.cpp : : : $(CXX14) $(JSON) ;
|
||||
|
||||
@@ -25,15 +25,26 @@ struct X3
|
||||
{
|
||||
};
|
||||
|
||||
struct X4
|
||||
struct V1
|
||||
{
|
||||
V1(int);
|
||||
};
|
||||
|
||||
struct V2
|
||||
{
|
||||
V2(int);
|
||||
};
|
||||
|
||||
struct V3
|
||||
{
|
||||
V3(int);
|
||||
};
|
||||
|
||||
struct Y: public X1, protected X2, private X3, public virtual V1, protected virtual V2, private virtual V3
|
||||
{
|
||||
};
|
||||
|
||||
struct Y: public X1, private X2, public virtual X3, private virtual X4
|
||||
{
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_STRUCT(Y, (X1, X2, X3, X4), ())
|
||||
BOOST_DESCRIBE_STRUCT(Y, (X1, X2, X3, V1, V2, V3), ())
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
@@ -57,22 +68,46 @@ int main()
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<X, mod_public>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<X, mod_protected>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<X, mod_private>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<Y, mod_any_access>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 4 );
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 6 );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X1 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_public );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, X2 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_private );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_protected );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 2>::type, X3 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 2>::modifiers), mod_public | mod_virtual );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 2>::modifiers), mod_private );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 3>::type, X4 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 3>::modifiers), mod_private | mod_virtual );
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 3>::type, V1 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 3>::modifiers), mod_public | mod_virtual );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 4>::type, V2 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 4>::modifiers), mod_protected | mod_virtual );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 5>::type, V3 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 5>::modifiers), mod_private | mod_virtual );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -83,28 +118,34 @@ int main()
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X1 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_public );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, X3 );
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, V1 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_public | mod_virtual );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<Y, mod_protected>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 2 );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X2 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_protected );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, V2 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_protected | mod_virtual );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<Y, mod_private>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 2 );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X2 );
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X3 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_private );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, X4 );
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, V3 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_private | mod_virtual );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<Y, mod_protected>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
119
test/compute_base_modifiers.cpp
Normal file
119
test/compute_base_modifiers.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
// 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/config.hpp>
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/describe/detail/compute_base_modifiers.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X1
|
||||
{
|
||||
};
|
||||
|
||||
struct X2
|
||||
{
|
||||
};
|
||||
|
||||
struct X3
|
||||
{
|
||||
};
|
||||
|
||||
struct V1
|
||||
{
|
||||
V1(int);
|
||||
};
|
||||
|
||||
struct V2
|
||||
{
|
||||
V2(int);
|
||||
};
|
||||
|
||||
struct V3
|
||||
{
|
||||
V3(int);
|
||||
};
|
||||
|
||||
struct Y: public X1, protected X2, private X3, public virtual V1, protected virtual V2, private virtual V3
|
||||
{
|
||||
};
|
||||
|
||||
struct Z final: public X1, protected X2, private X3, public virtual V1, protected virtual V2, private virtual V3
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::describe::detail;
|
||||
using namespace boost::describe;
|
||||
|
||||
BOOST_TEST( (is_public_base_of<X1, Y>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X1, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, X1>()), mod_public );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<X2, Y>::value) );
|
||||
BOOST_TEST( (is_protected_base_of<X2, Y>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X2, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, X2>()), mod_protected );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<X3, Y>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<X3, Y>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X3, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, X3>()), mod_private );
|
||||
|
||||
BOOST_TEST( (is_public_base_of<V1, Y>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V1, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, V1>()), mod_public | mod_virtual );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<V2, Y>::value) );
|
||||
BOOST_TEST( (is_protected_base_of<V2, Y>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V2, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, V2>()), mod_protected | mod_virtual );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<V3, Y>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<V3, Y>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V3, Y>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Y, V3>()), mod_private | mod_virtual );
|
||||
|
||||
BOOST_TEST( (is_public_base_of<X1, Z>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X1, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, X1>()), mod_public );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<X2, Z>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<X2, Z>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X2, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, X2>()), mod_private );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<X3, Z>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<X3, Z>::value) );
|
||||
BOOST_TEST( (!is_virtual_base_of<X3, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, X3>()), mod_private );
|
||||
|
||||
BOOST_TEST( (is_public_base_of<V1, Z>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V1, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, V1>()), mod_public | mod_virtual );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<V2, Z>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<V2, Z>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V2, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, V2>()), mod_private | mod_virtual );
|
||||
|
||||
BOOST_TEST( (!is_public_base_of<V3, Z>::value) );
|
||||
BOOST_TEST( (!is_protected_base_of<V3, Z>::value) );
|
||||
BOOST_TEST( (is_virtual_base_of<V3, Z>::value) );
|
||||
BOOST_TEST_EQ( (compute_base_modifiers<Z, V3>()), mod_private | mod_virtual );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
41
test/empty_enum_test.cpp
Normal file
41
test/empty_enum_test.cpp
Normal file
@@ -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/enumerators.hpp>
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
enum E1 {};
|
||||
BOOST_DESCRIBE_ENUM(E1)
|
||||
|
||||
BOOST_DEFINE_ENUM(E2)
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
using namespace boost::mp11;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
using D1 = boost::describe::describe_enumerators<E1>;
|
||||
BOOST_TEST_EQ( mp_size<D1>::value, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using D2 = boost::describe::describe_enumerators<E2>;
|
||||
BOOST_TEST_EQ( mp_size<D2>::value, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
@@ -6,6 +6,37 @@
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
enum E1
|
||||
{
|
||||
v1_1 = 5
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM(E1, v1_1);
|
||||
|
||||
BOOST_DEFINE_ENUM(E3, v3_1, v3_2, v3_3);
|
||||
|
||||
#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
|
||||
|
||||
enum class E2
|
||||
{
|
||||
v2_1,
|
||||
v2_2 = 7
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM(E2, v2_1, v2_2);
|
||||
|
||||
BOOST_DEFINE_FIXED_ENUM(E4, int, v4_1, v4_2, v4_3, v4_4);
|
||||
|
||||
BOOST_DEFINE_ENUM_CLASS(E5, v5_1, v5_2, v5_3, v5_4, v5_5);
|
||||
BOOST_DEFINE_FIXED_ENUM_CLASS(E6, int, v6_1, v6_2, v6_3, v6_4, v6_5, v6_6);
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
@@ -15,27 +46,6 @@ int main() {}
|
||||
|
||||
#else
|
||||
|
||||
enum E1
|
||||
{
|
||||
v1_1 = 5
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM(E1, v1_1);
|
||||
|
||||
enum class E2
|
||||
{
|
||||
v2_1,
|
||||
v2_2 = 7
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM_CLASS(E2, v2_1, v2_2);
|
||||
|
||||
BOOST_DEFINE_ENUM(E3, v3_1, v3_2, v3_3);
|
||||
BOOST_DEFINE_FIXED_ENUM(E4, int, v4_1, v4_2, v4_3, v4_4);
|
||||
|
||||
BOOST_DEFINE_ENUM_CLASS(E5, v5_1, v5_2, v5_3, v5_4, v5_5);
|
||||
BOOST_DEFINE_FIXED_ENUM_CLASS(E6, int, v6_1, v6_2, v6_3, v6_4, v6_5, v6_6);
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
using namespace boost::mp11;
|
||||
|
||||
@@ -144,3 +154,4 @@ int main()
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX11)
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
BOOST_DESCRIBE_CLASS(A2, (), (m1), (m2), (m3))
|
||||
};
|
||||
|
||||
struct B: public A1, private A2
|
||||
class A3
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -54,7 +54,24 @@ private:
|
||||
|
||||
int m3;
|
||||
|
||||
BOOST_DESCRIBE_CLASS(B, (A1, A2), (m1), (m2), (m3))
|
||||
BOOST_DESCRIBE_CLASS(A3, (), (m1), (m2), (m3))
|
||||
};
|
||||
|
||||
struct B: public A1, protected A2, private A3
|
||||
{
|
||||
public:
|
||||
|
||||
int m1;
|
||||
|
||||
protected:
|
||||
|
||||
int m2;
|
||||
|
||||
private:
|
||||
|
||||
int m3;
|
||||
|
||||
BOOST_DESCRIBE_CLASS(B, (A1, A2, A3), (m1), (m2), (m3))
|
||||
};
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
@@ -93,50 +110,65 @@ int main()
|
||||
{
|
||||
using L = describe_members<B, mod_protected | mod_inherited | mod_hidden>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 2 );
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 4 );
|
||||
|
||||
using D1 = mp_at_c<L, 0>;
|
||||
using D2 = mp_at_c<L, 1>;
|
||||
using D3 = mp_at_c<L, 2>;
|
||||
using D4 = mp_at_c<L, 3>;
|
||||
|
||||
// BOOST_TEST( D1::pointer == &B::A1::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D1::name, "m2" );
|
||||
BOOST_TEST_EQ( D1::modifiers, mod_protected | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D2::pointer == &B::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "m2" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_protected );
|
||||
// BOOST_TEST( D2::pointer == &B::A2::m1 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "m1" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_protected | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D3::pointer == &B::A2::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D3::name, "m2" );
|
||||
BOOST_TEST_EQ( D3::modifiers, mod_protected | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D4::pointer == &B::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D4::name, "m2" );
|
||||
BOOST_TEST_EQ( D4::modifiers, mod_protected );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_members<B, mod_private | mod_inherited | mod_hidden>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 5 );
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 6 );
|
||||
|
||||
using D1 = mp_at_c<L, 0>;
|
||||
using D2 = mp_at_c<L, 1>;
|
||||
using D3 = mp_at_c<L, 2>;
|
||||
using D4 = mp_at_c<L, 3>;
|
||||
using D5 = mp_at_c<L, 4>;
|
||||
using D6 = mp_at_c<L, 5>;
|
||||
|
||||
// BOOST_TEST( D1::pointer == &B::A1::m3 );
|
||||
BOOST_TEST_CSTR_EQ( D1::name, "m3" );
|
||||
BOOST_TEST_EQ( D1::modifiers, mod_private | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D2::pointer == &B::A2::m1 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "m1" );
|
||||
// BOOST_TEST( D2::pointer == &B::A2::m3 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "m3" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_private | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D3::pointer == &B::A2::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D3::name, "m2" );
|
||||
// BOOST_TEST( D3::pointer == &B::A3::m1 );
|
||||
BOOST_TEST_CSTR_EQ( D3::name, "m1" );
|
||||
BOOST_TEST_EQ( D3::modifiers, mod_private | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D4::pointer == &B::A2::m3 );
|
||||
BOOST_TEST_CSTR_EQ( D4::name, "m3" );
|
||||
// BOOST_TEST( D4::pointer == &B::A3::m2 );
|
||||
BOOST_TEST_CSTR_EQ( D4::name, "m2" );
|
||||
BOOST_TEST_EQ( D4::modifiers, mod_private | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D5::pointer == &B::m3 );
|
||||
// BOOST_TEST( D5::pointer == &B::A3::m3 );
|
||||
BOOST_TEST_CSTR_EQ( D5::name, "m3" );
|
||||
BOOST_TEST_EQ( D5::modifiers, mod_private );
|
||||
BOOST_TEST_EQ( D5::modifiers, mod_private | mod_inherited | mod_hidden );
|
||||
|
||||
// BOOST_TEST( D6::pointer == &B::m3 );
|
||||
BOOST_TEST_CSTR_EQ( D6::name, "m3" );
|
||||
BOOST_TEST_EQ( D6::modifiers, mod_private );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
82
test/overloaded_test.cpp
Normal file
82
test/overloaded_test.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/members.hpp>
|
||||
#include <boost/describe/class.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int f() { return 1; }
|
||||
int f() const { return 2; }
|
||||
|
||||
static int f( int x ) { return x; }
|
||||
static int f( int x, int y ) { return x + y; }
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_STRUCT(X, (), (
|
||||
(int ()) f,
|
||||
(int () const) f,
|
||||
(int (int)) f,
|
||||
(int (int, int)) f
|
||||
))
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::describe;
|
||||
using namespace boost::mp11;
|
||||
|
||||
{
|
||||
using L = describe_members<X, mod_any_access | mod_function>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 2 );
|
||||
|
||||
using D1 = mp_at_c<L, 0>;
|
||||
using D2 = mp_at_c<L, 1>;
|
||||
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( (x.*D1::pointer)(), 1 );
|
||||
BOOST_TEST_CSTR_EQ( D1::name, "f" );
|
||||
BOOST_TEST_EQ( D1::modifiers, mod_public | mod_function );
|
||||
|
||||
BOOST_TEST_EQ( (x.*D2::pointer)(), 2 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "f" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_public | mod_function );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_members<X, mod_any_access | mod_static | mod_function>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 2 );
|
||||
|
||||
using D1 = mp_at_c<L, 0>;
|
||||
|
||||
using D1 = mp_at_c<L, 0>;
|
||||
using D2 = mp_at_c<L, 1>;
|
||||
|
||||
BOOST_TEST_EQ( (*D1::pointer)( 3 ), 3 );
|
||||
BOOST_TEST_CSTR_EQ( D1::name, "f" );
|
||||
BOOST_TEST_EQ( D1::modifiers, mod_public | mod_static | mod_function );
|
||||
|
||||
BOOST_TEST_EQ( (*D2::pointer)( 4, 5 ), 9 );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "f" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_public | mod_static | mod_function );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
74
test/overloaded_test2.cpp
Normal file
74
test/overloaded_test2.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/members.hpp>
|
||||
#include <boost/describe/class.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <utility>
|
||||
|
||||
class X
|
||||
{
|
||||
private:
|
||||
|
||||
std::pair<int, int> p_;
|
||||
|
||||
public:
|
||||
|
||||
std::pair<int, int>& f() { return p_; }
|
||||
std::pair<int, int> const& f() const { return p_; }
|
||||
|
||||
BOOST_DESCRIBE_CLASS(X, (), ((std::pair<int, int>& ()) f, (std::pair<int, int> const& () const) f), (), (p_))
|
||||
};
|
||||
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::describe;
|
||||
using namespace boost::mp11;
|
||||
|
||||
{
|
||||
using L1 = describe_members<X, mod_any_access>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L1>::value, 1 );
|
||||
|
||||
using D1 = mp_at_c<L1, 0>;
|
||||
|
||||
BOOST_TEST_CSTR_EQ( D1::name, "p_" );
|
||||
BOOST_TEST_EQ( D1::modifiers, mod_private );
|
||||
|
||||
X x;
|
||||
|
||||
auto& p = x.*D1::pointer;
|
||||
|
||||
using L2 = describe_members<X, mod_any_access | mod_function>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L2>::value, 2 );
|
||||
|
||||
using D2 = mp_at_c<L2, 0>;
|
||||
using D3 = mp_at_c<L2, 1>;
|
||||
|
||||
BOOST_TEST_EQ( &(x.*D2::pointer)(), &p );
|
||||
BOOST_TEST_CSTR_EQ( D2::name, "f" );
|
||||
BOOST_TEST_EQ( D2::modifiers, mod_public | mod_function );
|
||||
|
||||
BOOST_TEST_EQ( &(x.*D3::pointer)(), &p );
|
||||
BOOST_TEST_CSTR_EQ( D3::name, "f" );
|
||||
BOOST_TEST_EQ( D3::modifiers, mod_public | mod_function );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
43
test/pp_call_test.cpp
Normal file
43
test/pp_call_test.cpp
Normal file
@@ -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)
|
||||
40
test/pp_is_empty_test.cpp
Normal file
40
test/pp_is_empty_test.cpp
Normal file
@@ -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)
|
||||
41
test/pp_is_paren_test.cpp
Normal file
41
test/pp_is_paren_test.cpp
Normal file
@@ -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)
|
||||
33
test/pp_name_test.cpp
Normal file
33
test/pp_name_test.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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
|
||||
|
||||
char const * s1 = BOOST_DESCRIBE_PP_NAME(x);
|
||||
char const * s2 = BOOST_DESCRIBE_PP_NAME(() y);
|
||||
char const * s3 = BOOST_DESCRIBE_PP_NAME((a) z);
|
||||
char const * s4 = BOOST_DESCRIBE_PP_NAME((a, b) w);
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( s1, "x" );
|
||||
BOOST_TEST_CSTR_EQ( s2, "y" );
|
||||
BOOST_TEST_CSTR_EQ( s3, "z" );
|
||||
BOOST_TEST_CSTR_EQ( s4, "w" );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX11)
|
||||
37
test/pp_parse_test.cpp
Normal file
37
test/pp_parse_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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
|
||||
|
||||
char const * s1 = S((BOOST_DESCRIBE_PP_PARSE(x)));
|
||||
char const * s2 = S((BOOST_DESCRIBE_PP_PARSE(() y)));
|
||||
char const * s3 = S((BOOST_DESCRIBE_PP_PARSE((a) z)));
|
||||
char const * s4 = S((BOOST_DESCRIBE_PP_PARSE((a, b) w)));
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( s1, "(0, ~, x)" );
|
||||
BOOST_TEST_CSTR_EQ( s2, "(1, (), y)" );
|
||||
BOOST_TEST_CSTR_EQ( s3, "(1, (a), z)" );
|
||||
BOOST_TEST_CSTR_EQ( s4, "(1, (a, b), w)" );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX11)
|
||||
40
test/pp_pointer_test.cpp
Normal file
40
test/pp_pointer_test.cpp
Normal file
@@ -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) S3(x)
|
||||
#define S3(x) S4(x)
|
||||
#define S4(x) #x
|
||||
|
||||
char const * s1 = S(BOOST_DESCRIBE_PP_POINTER(C1, x));
|
||||
char const * s2 = S((BOOST_DESCRIBE_PP_POINTER(C2, (R ()) y)));
|
||||
char const * s3 = S((BOOST_DESCRIBE_PP_POINTER(C3, (R () const) z)));
|
||||
char const * s4 = S((BOOST_DESCRIBE_PP_POINTER(C4, (R (A1)) v)));
|
||||
char const * s5 = S((BOOST_DESCRIBE_PP_POINTER(C5, (R (A1, A2) const &&) w)));
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( s1, "&C1::x" );
|
||||
BOOST_TEST_CSTR_EQ( s2, "(::boost::describe::detail::mfn<C2, R ()>(&C2::y))" );
|
||||
BOOST_TEST_CSTR_EQ( s3, "(::boost::describe::detail::mfn<C3, R () const>(&C3::z))" );
|
||||
BOOST_TEST_CSTR_EQ( s4, "(::boost::describe::detail::mfn<C4, R (A1)>(&C4::v))" );
|
||||
BOOST_TEST_CSTR_EQ( s5, "(::boost::describe::detail::mfn<C5, R (A1, A2) const &&>(&C5::w))" );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX11)
|
||||
76
test/test_d_type.cpp
Normal file
76
test/test_d_type.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/describe/class.hpp>
|
||||
|
||||
namespace N1
|
||||
{
|
||||
enum D
|
||||
{
|
||||
d
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM(D, d)
|
||||
}
|
||||
|
||||
namespace N2
|
||||
{
|
||||
enum E
|
||||
{
|
||||
D
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_ENUM(E, D)
|
||||
}
|
||||
|
||||
namespace N3
|
||||
{
|
||||
struct D
|
||||
{
|
||||
int d;
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_STRUCT(D, (), (d))
|
||||
}
|
||||
|
||||
namespace N4
|
||||
{
|
||||
struct E
|
||||
{
|
||||
int D;
|
||||
};
|
||||
|
||||
BOOST_DESCRIBE_STRUCT(E, (), (D))
|
||||
}
|
||||
|
||||
namespace N5
|
||||
{
|
||||
class D
|
||||
{
|
||||
int d;
|
||||
BOOST_DESCRIBE_CLASS(D, (), (), (), (d))
|
||||
};
|
||||
}
|
||||
|
||||
namespace N6
|
||||
{
|
||||
struct D {};
|
||||
struct E: D {};
|
||||
BOOST_DESCRIBE_STRUCT(E, (D), ())
|
||||
}
|
||||
|
||||
namespace N7
|
||||
{
|
||||
struct D {};
|
||||
class E: D
|
||||
{
|
||||
int d;
|
||||
BOOST_DESCRIBE_CLASS(E, (D), (), (), (d))
|
||||
};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
45
test/trailing_comma_test.cpp
Normal file
45
test/trailing_comma_test.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/describe/enumerators.hpp>
|
||||
#include <boost/describe/enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4003) // not enough arguments for macro invocation
|
||||
#endif
|
||||
|
||||
enum E1 { a1, b1, c1, };
|
||||
BOOST_DESCRIBE_ENUM(E1, a1, b1, c1, )
|
||||
|
||||
BOOST_DEFINE_ENUM(E2, a2, b2, c2, )
|
||||
|
||||
#if !defined(BOOST_DESCRIBE_CXX14)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because C++14 is not available")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
using namespace boost::mp11;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
using D1 = boost::describe::describe_enumerators<E1>;
|
||||
BOOST_TEST_EQ( mp_size<D1>::value, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
using D2 = boost::describe::describe_enumerators<E2>;
|
||||
BOOST_TEST_EQ( mp_size<D2>::value, 3 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_DESCRIBE_CXX14)
|
||||
Reference in New Issue
Block a user