Fixed missing const in constexpr methods

This fixeds build warnings with recent versions of clang (e.g. 8).

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/740/head
Florian Fleissner 5 years ago
parent 5e5e8d039b
commit ad74cc5740

@ -74,7 +74,7 @@ class Base {
typedef LEDs ThisType; typedef LEDs ThisType;
constexpr uint8_t offset() { constexpr uint8_t offset() const {
return offset_; return offset_;
} }
@ -124,7 +124,7 @@ class Base {
constexpr const ThisType &operator*() const { constexpr const ThisType &operator*() const {
return *this; return *this;
} }
constexpr bool isValid(uint8_t index) { constexpr bool isValid(uint8_t index) const {
return (_LEDDriverProps::led_count > 0 && index < _LEDDriverProps::led_count); return (_LEDDriverProps::led_count > 0 && index < _LEDDriverProps::led_count);
} }
} LEDs_; } LEDs_;

@ -39,10 +39,10 @@ class KeymapAdaptor {
: keymap_{keymap} : keymap_{keymap}
{} {}
constexpr Key getKey(uint8_t layer, uint8_t offset) { constexpr Key getKey(uint8_t layer, uint8_t offset) const {
return keymap_[layer][offset]; return keymap_[layer][offset];
} }
constexpr Key getKey(uint8_t layer, KeyAddr key_addr) { constexpr Key getKey(uint8_t layer, KeyAddr key_addr) const {
return this->getKey(layer, key_addr.toInt()); return this->getKey(layer, key_addr.toInt());
} }
}; };
@ -62,14 +62,14 @@ class AccumulationHelper : public KeymapAdaptor<_n_layers, _layer_size> {
typedef typename _Accumulation::ResultType ResultType; typedef typename _Accumulation::ResultType ResultType;
constexpr ResultType accumulateOnLayer(uint8_t layer, uint8_t offset) { constexpr ResultType accumulateOnLayer(uint8_t layer, uint8_t offset) const {
return (offset >= _layer_size) return (offset >= _layer_size)
? op_.init_value ? op_.init_value
: op_.apply(this->getKey(layer, offset), : op_.apply(this->getKey(layer, offset),
this->accumulateOnLayer(layer, offset + 1)); this->accumulateOnLayer(layer, offset + 1));
} }
constexpr ResultType accumulate(uint8_t layer) { constexpr ResultType accumulate(uint8_t layer) const {
return (layer >= _n_layers) return (layer >= _n_layers)
? op_.init_value ? op_.init_value
: op_.apply(this->accumulateOnLayer(layer, 0), : op_.apply(this->accumulateOnLayer(layer, 0),
@ -86,7 +86,7 @@ class AccumulationHelper : public KeymapAdaptor<_n_layers, _layer_size> {
op_{op} op_{op}
{} {}
constexpr ResultType apply() { constexpr ResultType apply() const {
return this->accumulate(0); return this->accumulate(0);
} }
}; };
@ -101,7 +101,7 @@ struct MaxKeyRaw {
typedef Key ResultType; typedef Key ResultType;
static constexpr ResultType init_value = 0; static constexpr ResultType init_value = 0;
constexpr ResultType apply(Key k1, Key k2) { constexpr ResultType apply(Key k1, Key k2) const {
return (k1 > k2) ? k1 : k2; return (k1 > k2) ? k1 : k2;
} }
}; };
@ -112,10 +112,10 @@ struct NumKeysEqual {
constexpr NumKeysEqual(Key k) : k_{k} {} constexpr NumKeysEqual(Key k) : k_{k} {}
constexpr ResultType apply(Key test_key, ResultType r) { constexpr ResultType apply(Key test_key, ResultType r) const {
return (test_key == k_) ? r + 1 : r; return (test_key == k_) ? r + 1 : r;
} }
constexpr ResultType apply(ResultType r1, ResultType r2) { constexpr ResultType apply(ResultType r1, ResultType r2) const {
return r1 + r2; return r1 + r2;
} }
@ -128,10 +128,10 @@ struct HasKey {
constexpr HasKey(Key k) : k_{k} {} constexpr HasKey(Key k) : k_{k} {}
constexpr ResultType apply(Key test_key, ResultType r) { constexpr ResultType apply(Key test_key, ResultType r) const {
return (test_key == k_) ? true : r; return (test_key == k_) ? true : r;
} }
constexpr ResultType apply(ResultType r1, ResultType r2) { constexpr ResultType apply(ResultType r1, ResultType r2) const {
return r1 || r2; return r1 || r2;
} }

Loading…
Cancel
Save