My Project
Functions
destroy_at.hpp File Reference

Go to the source code of this file.

Functions

template<typename T >
constexpr void bsl::destroy_at (T *const ptr) noexcept(noexcept(ptr->T::~T()))
 Calls the destructor of the object pointed to by ptr. More...
 

Detailed Description

Function Documentation

◆ destroy_at()

template<typename T >
constexpr void bsl::destroy_at ( T *const  ptr)
noexcept

Calls the destructor of the object pointed to by ptr.

#include <bsl/debug.hpp>
#include "example_class_subclass.hpp"
namespace bsl
{
inline void
example_destroy_at_overview() noexcept
{
example_class_subclass myclass{};
if (myclass.get()) {
bsl::print() << "success\n";
}
bsl::destroy_at(&myclass);
if (!myclass.get()) {
bsl::print() << "success\n";
}
}
}

SUPPRESSION: PRQA 4213 - false positive

  • We suppress this because M7-1-2 states that a parameter should be marked as a pointer to const if the parameter is not modified. This class call's the pointer's destructor, and therefor cannot labeled as const.
Template Parameters
Tdefines the type pointer to by ptr
Parameters
ptra pointer to the object to destroy
Exceptions
throwsif T throws during destruction