FastLED 3.9.15
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/ptr.h"
4#include "fl/shared_ptr.h"
5#include "fl/weak_ptr.h"
6#include "fl/unique_ptr.h"
7#include "fl/type_traits.h"
8
9namespace fl {
10
11// FastLED equivalent of std::intrusive_ptr<T>
12// NOTE: This is legacy - new code should use fl::shared_ptr<T> instead
13template <typename T>
15
16// FastLED equivalent of std::make_intrusive<T>
17// NOTE: This is legacy - new code should use fl::make_shared<T>(...) instead
18//
19// Usage:
20// auto ptr = fl::make_intrusive<MyClass>(arg1, arg2, ...);
21//
22// This is equivalent to:
23// fl::shared_ptr<MyClass> ptr = fl::make_intrusive<MyClass>(arg1, arg2, ...);
24//
25// Requirements:
26// - T must inherit from fl::Referent (for JSON UI compatibility)
27// - T must have a constructor that accepts the provided arguments
28template <typename T, typename... Args>
32
33// Convenience factory for the new pattern
34template <typename T, typename... Args>
38
39// Add make_unique function for consistency with std::make_unique
40template<typename T, typename... Args>
41typename fl::enable_if<!fl::is_array<T>::value, unique_ptr<T>>::type
42make_unique(Args&&... args) {
43 return unique_ptr<T>(new T(fl::forward<Args>(args)...));
44}
45
46// Add make_unique for arrays
47template<typename T>
48typename fl::enable_if<fl::is_array<T>::value, unique_ptr<T>>::type
50 typedef typename fl::remove_extent<T>::type U;
51 return unique_ptr<T>(new U[size]());
52}
53
54}
Definition ptr.h:114
static Ptr< T > New()
Definition ptr_impl.h:18
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args)
Definition memory.h:42
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348
__SIZE_TYPE__ size_t
Definition cstddef.h:17
fl::Ptr< T > intrusive_ptr
Definition memory.h:14
intrusive_ptr< T > make_intrusive(Args &&... args)
Definition memory.h:29
fl::shared_ptr< T > make_shared_ptr(Args &&... args)
Definition memory.h:35
constexpr T && forward(typename remove_reference< T >::type &t) noexcept
IMPORTANT!
Definition crgb.h:20
corkscrew_args args
Definition old.h:150