File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -305,9 +305,6 @@ class NimBLEAttValue {
305305 */
306306 template <typename T>
307307 T getValue (time_t * timestamp = nullptr , bool skipSizeCheck = false ) const {
308- if (!skipSizeCheck && size () < sizeof (T)) {
309- return T ();
310- }
311308 if (timestamp != nullptr ) {
312309# if CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED
313310 *timestamp = m_timestamp;
@@ -316,7 +313,14 @@ class NimBLEAttValue {
316313# endif
317314 }
318315
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+ }
320324 }
321325
322326 /* ********************** Operators ************************/
You can’t perform that action at this time.
0 commit comments