diff --git a/dart/common/MemoryAllocator.hpp b/dart/common/MemoryAllocator.hpp index 7139ae2b344e5..58c02f2043ece 100644 --- a/dart/common/MemoryAllocator.hpp +++ b/dart/common/MemoryAllocator.hpp @@ -69,7 +69,7 @@ class DART_API MemoryAllocator : public Castable /// memory. /// @return On failure, a null pointer [[nodiscard]] virtual void* allocate(size_t bytes) noexcept = 0; - // TODO(JS): Make this constexpr once migrated to C++20 + // Note: Virtual runtime allocation cannot be constexpr by design. /// Allocates object(s) without calling the constructor. /// @@ -85,7 +85,7 @@ class DART_API MemoryAllocator : public Castable /// @param[in] pointer: Pointer obtained from allocate(). /// @param[in] bytes: The bytes of the allocated memory. virtual void deallocate(void* pointer, size_t bytes) = 0; - // TODO(JS): Make this constexpr once migrated to C++20 + // Note: Virtual runtime deallocation cannot be constexpr by design. /// Allocates uninitialized storage and constructs an object of type T to the /// allocated storage. diff --git a/dart/common/MemoryManager.hpp b/dart/common/MemoryManager.hpp index 3c2e82b2fcc5e..08b62dde42c09 100644 --- a/dart/common/MemoryManager.hpp +++ b/dart/common/MemoryManager.hpp @@ -110,7 +110,7 @@ class DART_API MemoryManager final /// @param[in] pointer: Pointer obtained from allocate(). /// @param[in] bytes: The bytes of the allocated memory. void deallocate(Type type, void* pointer, size_t bytes); - // TODO(JS): Make this constexpr once migrated to C++20 + // Note: Deallocates runtime memory; constexpr is not applicable. void deallocateUsingFree(void* pointer, size_t bytes); diff --git a/dart/common/StlAllocator.hpp b/dart/common/StlAllocator.hpp index fcc0b576f9962..e280d5ee4aa65 100644 --- a/dart/common/StlAllocator.hpp +++ b/dart/common/StlAllocator.hpp @@ -85,10 +85,13 @@ class StlAllocator : public std::allocator /// /// @param[in] pointer: Pointer obtained from allocate(). /// @param[in] n: Number of objects earlier passed to allocate(). - void deallocate(pointer pointer, size_type n); - // TODO(JS): Make this constexpr once migrated to C++20 + void deallocate(pointer pointer, size_type n) noexcept; - // TODO(JS): Add size_type max_size() const noexcept; + /// Upper bound on elements that can be allocated. + [[nodiscard]] constexpr size_type max_size() const noexcept + { + return std::allocator_traits::max_size(*this); + } /// Prints state of the memory allocator void print(std::ostream& os = std::cout, int indent = 0) const; diff --git a/dart/common/detail/StlAllocator-impl.hpp b/dart/common/detail/StlAllocator-impl.hpp index 182bf822fc874..0c4632655bab8 100644 --- a/dart/common/detail/StlAllocator-impl.hpp +++ b/dart/common/detail/StlAllocator-impl.hpp @@ -80,7 +80,7 @@ typename StlAllocator::pointer StlAllocator::allocate( //============================================================================== template -void StlAllocator::deallocate(pointer pointer, size_type n) +void StlAllocator::deallocate(pointer pointer, size_type n) noexcept { mBaseAllocator.deallocate(pointer, n * sizeof(T)); } diff --git a/examples/heightmap/main.cpp b/examples/heightmap/main.cpp index c7aa27781c424..612ae12e59283 100644 --- a/examples/heightmap/main.cpp +++ b/examples/heightmap/main.cpp @@ -92,7 +92,6 @@ dynamics::SimpleFramePtr createHeightmapFrame( terrainFrame->createVisualAspect(); - // TODO(JS): Remove? auto terrainShape = createHeightmapShape( xResolution, yResolution, xSize, ySize, zMin, zMax); terrainFrame->setShape(terrainShape);