Skip to content

Commit 20bc030

Browse files
committed
use dollar macro
1 parent ee87364 commit 20bc030

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

include/rsl/_impl/macro/attributes.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@
2424
# define RSL_ENABLE_IF(...) __attribute__((enable_if(__VA_ARGS__)))
2525
#else
2626
# define RSL_ENABLE_IF(...)
27-
#endif
27+
#endif
28+
29+
#define $inline(...) RSL_INLINE(__VA_ARGS__)
30+
#define $enable_if(...) RSL_ENABLE_IF(__VA_ARGS__)

include/rsl/_impl/member_cache.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ namespace rsl::_impl {
1212
template <std::meta::info... Members>
1313
struct MemberAccessor {
1414
template <std::size_t Idx, typename S>
15-
RSL_INLINE(always)
16-
constexpr static decltype(auto) get(S&& storage) noexcept {
15+
$inline(always) constexpr static decltype(auto) get(S&& storage) noexcept {
1716
return std::forward_like<S>(storage.[:Members...[Idx]:]);
1817
}
1918

2019
template <std::size_t Idx, typename S>
21-
RSL_INLINE(always)
22-
constexpr static decltype(auto) get_addr(S&& storage) noexcept {
20+
$inline(always) constexpr static decltype(auto) get_addr(S&& storage) noexcept {
2321
return std::addressof(std::forward<S>(storage).[:Members...[Idx]:]);
2422
}
2523

26-
constexpr static auto count = sizeof...(Members);
27-
constexpr static std::array<std::meta::info, count> types = {dealias(type_of(Members))...};
24+
constexpr static auto count = sizeof...(Members);
25+
constexpr static std::array<std::meta::info, count> types = {dealias(type_of(Members))...};
2826
constexpr static std::array<std::meta::info, count> members = {Members...};
2927

3028
static consteval std::size_t get_index_of(std::meta::info needle) {
@@ -48,19 +46,19 @@ struct MemberAccessor {
4846
std::vector<std::string_view> names;
4947
names.reserve(count);
5048
for (auto member : std::vector<std::meta::info>{Members...}) {
51-
if (not has_identifier(member)) { continue; }
49+
if (not has_identifier(member)) {
50+
continue;
51+
}
5252
names.push_back(identifier_of(member));
5353
}
54-
54+
5555
if (auto it = std::ranges::find(names, name); it != names.end()) {
5656
return std::distance(names.begin(), it);
5757
}
5858
return -1UZ;
5959
}
6060

61-
static consteval bool has_member(std::string_view name) {
62-
return get_index_of(name) != -1UZ;
63-
}
61+
static consteval bool has_member(std::string_view name) { return get_index_of(name) != -1UZ; }
6462
};
6563

6664
template <auto... Members>

include/rsl/trie

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ struct State {
2323
rsl::string_view prefix;
2424
int word_index;
2525

26-
RSL_INLINE(always)
27-
constexpr int visit(std::string_view str) const {
26+
$inline(always) constexpr int visit(std::string_view str) const {
2827
// assumes the prefix is never empty
2928
//? empty prefixes are only allowed at the root note
3029
if (str.empty() || str[0] != prefix[0] || str.size() < prefix.size()) {

include/rsl/variant

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,13 @@ struct VisitImpl {
159159
template <key_type Tag, std::size_t... Idx>
160160
struct Dispatch<Tag, std::index_sequence<Idx...>> {
161161
template <typename F, typename... U>
162-
RSL_INLINE(always)
163-
constexpr static decltype(auto) visit(F&& visitor, U&&... variants) {
162+
$inline(always) constexpr static decltype(auto) visit(F&& visitor, U&&... variants) {
164163
return std::forward<F>(visitor)(std::forward<U>(variants).template get_alt<Tag[Idx]>()...);
165164
}
166165
};
167166

168167
template <std::size_t Idx, typename F, typename... U>
169-
RSL_INLINE(always)
170-
constexpr static decltype(auto) visit(F&& visitor, U&&... variants) {
168+
$inline(always) constexpr static decltype(auto) visit(F&& visitor, U&&... variants) {
171169
return Dispatch<key_type{Idx}>::visit(std::forward<F>(visitor), std::forward<U>(variants)...);
172170
}
173171
};
@@ -178,7 +176,7 @@ struct VisitImpl<Variant> {
178176
static constexpr std::size_t max_index = variant_size<std::remove_cvref_t<Variant>>::value;
179177

180178
template <std::size_t Idx, typename F, typename U>
181-
RSL_INLINE(always) constexpr static decltype(auto) visit(F&& visitor, U&& variant) {
179+
$inline(always) constexpr static decltype(auto) visit(F&& visitor, U&& variant) {
182180
return std::forward<F>(visitor)(std::forward<U>(variant).template get_alt<Idx>());
183181
}
184182
};

0 commit comments

Comments
 (0)