| 1 |
// PR c++/80174 |
| 2 |
|
| 3 |
typedef unsigned char uint8_t; |
| 4 |
|
| 5 |
template <typename T> |
| 6 |
struct HighestMaxFieldIdx { |
| 7 |
static const uint8_t maxFieldIdx = T::fieldIdx; |
| 8 |
}; |
| 9 |
|
| 10 |
template <typename This> |
| 11 |
struct Outer { |
| 12 |
|
| 13 |
template <uint8_t _fieldIdx, typename T, T This::*field> |
| 14 |
struct Varint {}; |
| 15 |
|
| 16 |
|
| 17 |
template <uint8_t _fieldIdx, uint8_t This::*field> |
| 18 |
struct Varint<_fieldIdx, uint8_t, field> { |
| 19 |
static const uint8_t fieldIdx = _fieldIdx; |
| 20 |
}; |
| 21 |
}; |
| 22 |
|
| 23 |
struct Msg { |
| 24 |
uint8_t a; |
| 25 |
|
| 26 |
static const uint8_t t |
| 27 |
= HighestMaxFieldIdx<Outer<Msg>::Varint<1, uint8_t, &Msg::a> >::maxFieldIdx; |
| 28 |
}; |