#pragma once #include "fl/ptr.h" #include "fl/shared_ptr.h" #include "fl/weak_ptr.h" #include "fl/unique_ptr.h" #include "fl/type_traits.h" namespace fl { // FastLED equivalent of std::intrusive_ptr // NOTE: This is legacy - new code should use fl::shared_ptr instead template using intrusive_ptr = fl::Ptr; // FastLED equivalent of std::make_intrusive // NOTE: This is legacy - new code should use fl::make_shared(...) instead // // Usage: // auto ptr = fl::make_intrusive(arg1, arg2, ...); // // This is equivalent to: // fl::shared_ptr ptr = fl::make_intrusive(arg1, arg2, ...); // // Requirements: // - T must inherit from fl::Referent (for JSON UI compatibility) // - T must have a constructor that accepts the provided arguments template intrusive_ptr make_intrusive(Args&&... args) { return intrusive_ptr::New(fl::forward(args)...); } // Convenience factory for the new pattern template fl::shared_ptr make_shared_ptr(Args&&... args) { return fl::make_shared(fl::forward(args)...); } // Add make_unique function for consistency with std::make_unique template typename fl::enable_if::value, unique_ptr>::type make_unique(Args&&... args) { return unique_ptr(new T(fl::forward(args)...)); } // Add make_unique for arrays template typename fl::enable_if::value, unique_ptr>::type make_unique(fl::size_t size) { typedef typename fl::remove_extent::type U; return unique_ptr(new U[size]()); } }