Cgu::GSliceFreeSize< block_size > Class Template Reference
handles and smart pointers

A deleter functor for use as the second (Dealloc) template parameter of the SharedHandle, SharedLockHandle or ScopedHandle template classes, which calls glib's g_slice_free1(). More...

`#include <c++-gtk-utils/shared_handle.h>`

## Public Member Functions

void | operator() (const void *obj) noexcept

## Detailed Description

### template<gsize block_size>
class Cgu::GSliceFreeSize< block_size >

A deleter functor for use as the second (Dealloc) template parameter of the SharedHandle, SharedLockHandle or ScopedHandle template classes, which calls glib's g_slice_free1().

This functor enables those classes to manage memory allocated with g_slice_alloc(), g_slice_alloc0() or g_slice_copy(). It is an alternative to using GSliceFree where, instead of the template parameter being a pointer to a particular managed type, the size of the memory block to be freed is passed, so enabling it to be more conveniently used to free memory containing arrays of built-in types or of PODSs. Use GSliceDestroy where the memory holds a C++ object constructed in the memory by the global placement new expression.

The type of the template argument for the functor is an integer type (gsize) and is the size of the block to be managed. For example:

using namespace Cgu;
SharedHandle<char*, GSliceFreeSize<10> > h(static_cast<char*>(g_slice_alloc(10)));
...

The availability of this functor is not dependent on the library having been installed with the --with-glib-memory-slices-compat or --with-glib-memory-slices-no-compat configuration option (see Memory allocation for further details of those options).

## Member Function Documentation

## operator()()

template<gsize block_size>

void Cgu::GSliceFreeSize< block_size >::operator() | ( | const void * | obj | ) |

inline noexcept

The documentation for this class was generated from the following file:

- shared_handle.h

Cgu
Definition: application.h:44
Cgu::SharedHandle
This is a generic class for managing the lifetime of objects allocated on freestore.
Definition: shared_handle.h:451