8000 Merge pull request #3 from zauguin/master · jll63/yomm11@1fd8a76 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #3 from zauguin/master
Browse files Browse the repository at this point in the history
Feature detect constexpr and added constructor
  • Loading branch information
jll63 committed Jun 16, 2015
2 parents 106a248 + 38578f5 commit 1fd8a76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/yorel/multi_methods/extern_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

#define MULTI_METHOD(ID, RETURN_TYPE, ARGS...) \
template<typename Sig> struct ID ## _specialization; \
constexpr ::yorel::multi_methods::multi_method<ID ## _specialization, RETURN_TYPE(ARGS)> ID{}; \
YOMM_CONSTEXPR ::yorel::multi_methods::multi_method<ID ## _specialization, RETURN_TYPE(ARGS)> ID; \
YOREL_MM_TRACE(inline const char* _yomm11_name_(::yorel::multi_meth 8000 ods::multi_method<ID ## _specialization, RETURN_TYPE(__VA_ARGS__)>*) { return #ID; }) \
extern template class ::yorel::multi_methods::detail::multi_method_implementation<RETURN_TYPE, ARGS>
8 changes: 7 additions & 1 deletion include/yorel/multi_methods/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
#define MM_INIT_MULTI(BASE) \
this->BASE::_init_yomm11_ptr(this)

#ifdef __cpp_constexpr
#define YOMM_CONSTEXPR constexpr
#else
#define YOMM_CONSTEXPR const
#endif

#undef MULTI_METHOD
#define MULTI_METHOD(ID, RETURN_TYPE, ...) \
template<typename Sig> struct ID ## _specialization; \
YOREL_MM_TRACE(inline const char* _yomm11_name_(::yorel::multi_methods::multi_method<ID ## _specialization, RETURN_TYPE(__VA_ARGS__)>*) { return #ID; }) \
const ::yorel::multi_methods::multi_method<ID ## _specialization, RETURN_TYPE(__VA_ARGS__)> ID
YOMM_CONSTEXPR ::yorel::multi_methods::multi_method<ID ## _specialization, RETURN_TYPE(__VA_ARGS__)> ID

#define BEGIN_SPECIALIZATION(ID, RESULT, ...) \
template<> \
Expand Down
84A9
4 changes: 4 additions & 0 deletions include/yorel/multi_methods/no_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ mm_class::initializer<Class, mm_class::base_list<Bases...>> mm_class::initialize
template<template<typename Sig> class Method, typename R, typename... P>
struct multi_method<Method, R(P...)> {

#ifdef __cpp_constexpr
constexpr
#endif
multi_method() {}
R operator ()(typename detail::remove_virtual<P>::type... args) const;
static R method(typename detail::remove_virtual<P>::type... args);

Expand Down

0 comments on commit 1fd8a76

Please sign in to comment.
0