/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */

/*
 * This is a special header file for compatibility with the C++ STL and Arduino library part
 */


#ifndef ECXX_PLATFORM_NODEMCU_LIBCPPCOMPAT_MEMORY_H
#define ECXX_PLATFORM_NODEMCU_LIBCPPCOMPAT_MEMORY_H


//
// Include the eCxx header files
//
#include <eCxx/CTL/UniquePtr.h>
#include <eCxx/CTL/WeakPtr.h>


//
// Emulate some C++ STL features as minimum as possible
//
namespace std {


    // Emulate std::default_delete<T>
    template <typename ValueT>
    using default_delete = eCxx::Ext::DefaultDeleter<ValueT>;


    // Emulate std::unique_ptr<T>
    template<typename ValueT>
    using unique_ptr = eCxx::Ext::UniquePtr<ValueT>;


    // Emulate std::shared_ptr<T>
    template<typename ValueT>
    using shared_ptr = eCxx::Ext::SharedPtr<ValueT>;


    // Emulate std::make_shared<T, A...>
    template<typename ValueT, typename... Args>
    inline auto make_shared(Args&&... args) -> decltype( eCxx::Ext::makeSharedPtr<ValueT>( eCxx::forward<Args>(args)... ) )
    { return eCxx::Ext::makeSharedPtr<ValueT>( eCxx::forward<Args>(args)... ); }


    // Emulate std::weak_ptr<T>
    template<typename ValueT>
    using weak_ptr = eCxx::Ext::WeakPtr<ValueT>;


} // namespace std


#endif
