From c5fd5612996a44e9e7387eb30ecebf5c7011e5ce Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Thu, 25 Aug 2016 10:06:22 -0500 Subject: [PATCH] Improve SingletonPtr const correctness Make all the functions of SingletonPtr const for improved const correctness. --- hal/api/SingletonPtr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hal/api/SingletonPtr.h b/hal/api/SingletonPtr.h index 820c8ed7d17..08160d28880 100644 --- a/hal/api/SingletonPtr.h +++ b/hal/api/SingletonPtr.h @@ -73,7 +73,7 @@ struct SingletonPtr { * @returns * A pointer to the singleton */ - T* get() { + T* get() const { if (NULL == _ptr) { singleton_lock(); if (NULL == _ptr) { @@ -92,14 +92,14 @@ struct SingletonPtr { * @returns * A pointer to the singleton */ - T* operator->() { + T* operator->() const { return get(); } // This is zero initialized when in global scope - T *_ptr; + mutable T * _ptr; // Force data to be 4 byte aligned - uint32_t _data[(sizeof(T) + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; + mutable uint32_t _data[(sizeof(T) + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; }; #endif