Skip to content

Commit 429fb2b

Browse files
committed
Use reflection instead of FirstMember{}
1 parent 966aab4 commit 429fb2b

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

GPU/Common/MemLayout.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ struct AggregateConstructor {
6363
constexpr SF operator()(const Args& ...args) const { return {args...}; }
6464
};
6565

66-
struct FirstMember {
67-
template <class T, class... Args>
68-
constexpr T& operator()(T& t, Args& ...args) const { return t; }
69-
template <class T, class... Args>
70-
constexpr const T& operator()(const T& t, const Args& ...args) const { return t; }
71-
};
72-
7366
template <class SF>
7467
struct PreIncrement {
7568
template <class... Args>
@@ -333,22 +326,22 @@ struct wrapper<S, pointer> : public S<pointer> {
333326
constexpr wrapper<S, const_reference> operator->() const { return operator[](0); }
334327

335328
constexpr bool operator==(const wrapper& other) const {
336-
return apply(*this, FirstMember{}) == apply(other, FirstMember{}); }
329+
return this->[:nsdms(^^Base)[0]:] == other.[:nsdms(^^Base)[0]:]; }
337330
constexpr bool operator!=(const wrapper& other) const {
338331
return !this->operator==(other); }
339332
constexpr bool operator<(const wrapper& other) const {
340-
return apply(*this, FirstMember{}) < apply(other, FirstMember{}); }
333+
return this->[:nsdms(^^Base)[0]:] < other.[:nsdms(^^Base)[0]:]; }
341334
constexpr bool operator<=(const wrapper& other) const {
342-
return apply(*this, FirstMember{}) <= apply(other, FirstMember{}); }
335+
return this->[:nsdms(^^Base)[0]:] <= other.[:nsdms(^^Base)[0]:]; }
343336
constexpr bool operator>(const wrapper& other) const {
344-
return apply(*this, FirstMember{}) > apply(other, FirstMember{}); }
337+
return this->[:nsdms(^^Base)[0]:] > other.[:nsdms(^^Base)[0]:]; }
345338
constexpr bool operator>=(const wrapper& other) const {
346-
return apply(*this, FirstMember{}) >= apply(other, FirstMember{}); }
339+
return this->[:nsdms(^^Base)[0]:] >= other.[:nsdms(^^Base)[0]:]; }
347340

348341
constexpr wrapper operator+(ptrdiff_t i) const { return apply(*this, Advance<Base>{i}); }
349342
constexpr wrapper operator-(ptrdiff_t i) const { return operator+(-i); }
350343
constexpr ptrdiff_t operator-(const wrapper& other) const {
351-
return apply(*this, FirstMember{}) - apply(other, FirstMember{}); }
344+
return this->[:nsdms(^^Base)[0]:] - other.[:nsdms(^^Base)[0]:]; }
352345

353346
constexpr wrapper& operator++() { apply(*this, PreIncrement<Base>{}); return *this; }
354347
constexpr wrapper& operator+=(ptrdiff_t i) { return *this = *this + i; }
@@ -370,17 +363,17 @@ struct wrapper<S, const_pointer> : public S<const_pointer> {
370363
constexpr wrapper<S, const_reference> operator->() const { return operator[](0); }
371364

372365
constexpr bool operator==(const wrapper& other) const {
373-
return apply(*this, FirstMember{}) == apply(other, FirstMember{}); }
366+
return this->[:nsdms(^^Base)[0]:] == other.[:nsdms(^^Base)[0]:]; }
374367
constexpr bool operator!=(const wrapper& other) const {
375368
return !this->operator==(other); }
376369
constexpr bool operator<(const wrapper& other) const {
377-
return apply(*this, FirstMember{}) < apply(other, FirstMember{}); }
370+
return this->[:nsdms(^^Base)[0]:] < other.[:nsdms(^^Base)[0]:]; }
378371

379372
constexpr wrapper operator+(ptrdiff_t i) const {
380373
return apply(*this, Advance<Base>{i}); }
381374
constexpr wrapper operator-(ptrdiff_t i) const { return operator+(-i); }
382375
constexpr ptrdiff_t operator-(const wrapper& other) const {
383-
return apply(*this, FirstMember{}) - apply(other, FirstMember{}); }
376+
return this->[:nsdms(^^Base)[0]:] - other.[:nsdms(^^Base)[0]:]; }
384377

385378
constexpr wrapper& operator++() { apply(*this, PreIncrement<Base>{}); return *this; }
386379
constexpr wrapper& operator+=(ptrdiff_t i) { return *this = *this + i; }

0 commit comments

Comments
 (0)