File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -305,9 +305,6 @@ class NimBLEAttValue {
305
305
*/
306
306
template <typename T>
307
307
T getValue (time_t * timestamp = nullptr , bool skipSizeCheck = false ) const {
308
- if (!skipSizeCheck && size () < sizeof (T)) {
309
- return T ();
310
- }
311
308
if (timestamp != nullptr ) {
312
309
# if CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED
313
310
*timestamp = m_timestamp;
@@ -316,7 +313,14 @@ class NimBLEAttValue {
316
313
# endif
317
314
}
318
315
319
- return *(reinterpret_cast <const T*>(m_attr_value));
316
+ if (std::is_convertible<NimBLEAttValue, T>::value) {
317
+ return *this ;
318
+ } else {
319
+ if (!skipSizeCheck && size () < sizeof (T)) {
320
+ return T ();
321
+ }
322
+ return *(reinterpret_cast <const T*>(m_attr_value));
323
+ }
320
324
}
321
325
322
326
/* ********************** Operators ************************/
You can’t perform that action at this time.
0 commit comments