Skip to content

Commit 6abb1c7

Browse files
committed
TICK_MEMBER_REQUIRES_OC for outside-class-definitions of members
1 parent 3a70ee5 commit 6abb1c7

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

doc/src/requires.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ struct foo
5757
};
5858
```
5959
60+
If the member is defined outside of the class, use `TICK_MEMBER_REQUIRES_OC` (OC: outside_class) outside the class. For example,
61+
```cpp
62+
template<class T>
63+
struct foo
64+
{
65+
T x;
66+
67+
TICK_MEMBER_REQUIRES(is_incrementable<T>())
68+
void up();
69+
};
70+
71+
template<class T>
72+
TICK_MEMBER_REQUIRES_OC(is_incrementable<T>())
73+
void foo<T>::up()
74+
{
75+
x++;
76+
}
77+
```
78+
6079
TICK_PARAM_REQUIRES
6180
--------------------
6281

tick/requires.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ trait(Ts&&...) noexcept
5353

5454
#define TICK_CLASS_REQUIRES(...) typename std::enable_if<(__VA_ARGS__)>::type
5555

56-
#define TICK_REQUIRES(...) bool TickPrivateBool ## __LINE__=true, typename std::enable_if<(TickPrivateBool##__LINE__ && __VA_ARGS__), int>::type = 0
56+
#define TICK_REQUIRES(...) bool TickPrivateBool ## __LINE__=true, typename std::enable_if<(TickPrivateBool##__LINE__ && __VA_ARGS__), int>::type = 0
57+
#define TICK_REQUIRES_OC(...) bool TickPrivateBool ## __LINE__, typename std::enable_if<(TickPrivateBool##__LINE__ && __VA_ARGS__), int>::type
5758

58-
#define TICK_MEMBER_REQUIRES(...) template<TICK_REQUIRES(__VA_ARGS__)>
59+
#define TICK_MEMBER_REQUIRES(...) template<TICK_REQUIRES( __VA_ARGS__)>
60+
#define TICK_MEMBER_REQUIRES_OC(...) template<TICK_REQUIRES_OC(__VA_ARGS__)>
5961

6062
#define TICK_PARAM_REQUIRES(...) \
6163
typename std::enable_if< \
6264
(tick::detail::param_extract<decltype(__VA_ARGS__)>::value), \
6365
typename tick::detail::private_enum<__LINE__>::type \
6466
>::type = tick::detail::private_enum<__LINE__>::type::na
6567

66-
#endif
68+
#endif

0 commit comments

Comments
 (0)