Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
8148d03c
Commit
8148d03c
authored
Feb 27, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CAF_ADD_TYPE_ID on MSVC
parent
fd02800e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
22 deletions
+51
-22
libcaf_core/caf/detail/pp.hpp
libcaf_core/caf/detail/pp.hpp
+4
-0
libcaf_core/caf/type_id.hpp
libcaf_core/caf/type_id.hpp
+47
-22
No files found.
libcaf_core/caf/detail/pp.hpp
View file @
8148d03c
...
@@ -29,6 +29,10 @@
...
@@ -29,6 +29,10 @@
/// Evaluate x and y before concatenating into a single token.
/// Evaluate x and y before concatenating into a single token.
#define CAF_PP_PASTE(x, y) CAF_PP_CAT(x, y)
#define CAF_PP_PASTE(x, y) CAF_PP_CAT(x, y)
/// Evaluates to __COUNTER__. Allows delaying evaluation of __COUNTER__ in some
/// edge cases where it otherwise could increment the internal counter twice.
#define CAF_PP_COUNTER() __COUNTER__
#ifdef CAF_MSVC
#ifdef CAF_MSVC
/// Computes the number of arguments of a variadic pack.
/// Computes the number of arguments of a variadic pack.
...
...
libcaf_core/caf/type_id.hpp
View file @
8148d03c
...
@@ -98,8 +98,32 @@ constexpr type_id_t first_custom_type_id = 200;
...
@@ -98,8 +98,32 @@ constexpr type_id_t first_custom_type_id = 200;
constexpr type_id_t project_name##_first_type_id = first_id; \
constexpr type_id_t project_name##_first_type_id = first_id; \
}
}
#ifdef CAF_MSVC
/// Assigns the next free type ID to `fully_qualified_name`.
/// Assigns the next free type ID to `fully_qualified_name`.
#define CAF_ADD_TYPE_ID(project_name, fully_qualified_name) \
# define CAF_ADD_TYPE_ID(project_name, fully_qualified_name) \
namespace caf { \
template <> \
struct type_id<CAF_PP_EXPAND fully_qualified_name> { \
static constexpr type_id_t value \
= project_name##_first_type_id \
+ (CAF_PP_CAT(CAF_PP_COUNTER, ()) \
- project_name##_type_id_counter_init - 1); \
}; \
template <> \
struct type_by_id<type_id<CAF_PP_EXPAND fully_qualified_name>::value> { \
using type = CAF_PP_EXPAND fully_qualified_name; \
}; \
template <> \
struct type_name<CAF_PP_EXPAND fully_qualified_name> { \
static constexpr const char* value \
= CAF_PP_STR(CAF_PP_EXPAND fully_qualified_name); \
}; \
template <> \
struct type_name_by_id<type_id<CAF_PP_EXPAND fully_qualified_name>::value> \
: type_name<CAF_PP_EXPAND fully_qualified_name> {}; \
}
#else
# define CAF_ADD_TYPE_ID(project_name, fully_qualified_name) \
namespace caf { \
namespace caf { \
template <> \
template <> \
struct type_id<CAF_PP_EXPAND fully_qualified_name> { \
struct type_id<CAF_PP_EXPAND fully_qualified_name> { \
...
@@ -120,6 +144,7 @@ constexpr type_id_t first_custom_type_id = 200;
...
@@ -120,6 +144,7 @@ constexpr type_id_t first_custom_type_id = 200;
struct type_name_by_id<type_id<CAF_PP_EXPAND fully_qualified_name>::value> \
struct type_name_by_id<type_id<CAF_PP_EXPAND fully_qualified_name>::value> \
: type_name<CAF_PP_EXPAND fully_qualified_name> {}; \
: type_name<CAF_PP_EXPAND fully_qualified_name> {}; \
}
}
#endif
/// Creates a new tag type (atom) in the global namespace and assigns the next
/// Creates a new tag type (atom) in the global namespace and assigns the next
/// free type ID to it.
/// free type ID to it.
...
@@ -154,7 +179,7 @@ constexpr type_id_t first_custom_type_id = 200;
...
@@ -154,7 +179,7 @@ constexpr type_id_t first_custom_type_id = 200;
return f(caf::meta::type_name(#atom_namespace "::" #atom_name)); \
return f(caf::meta::type_name(#atom_namespace "::" #atom_name)); \
} \
} \
} \
} \
CAF_ADD_TYPE_ID(project_name, (atom_namespace
::atom_name))
CAF_ADD_TYPE_ID(project_name, (atom_namespace::atom_name))
#ifdef CAF_MSVC
#ifdef CAF_MSVC
# define CAF_ADD_ATOM(...) \
# define CAF_ADD_ATOM(...) \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment