Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:58

0001 // Copyright (c) 2023 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Standard_MemoryUtils_HeaderFile
0015 #define _Standard_MemoryUtils_HeaderFile
0016 
0017 #include <NCollection_Allocator.hxx>
0018 #include <NCollection_OccAllocator.hxx>
0019 
0020 #include <memory>
0021 
0022 namespace opencascade
0023 {
0024   template< class T, class... Args >
0025   std::shared_ptr<T> make_shared(Args&&... theArgs)
0026   {
0027     return std::allocate_shared<T, NCollection_Allocator<T>, Args...>(NCollection_Allocator<T>(),
0028                                                                       std::forward<Args>(theArgs)...);
0029   }
0030 
0031   template< class T, class... Args >
0032   std::shared_ptr<T> make_oshared(const Handle(NCollection_BaseAllocator)& theAlloc,
0033                                   Args&&... theArgs)
0034   {
0035     return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(NCollection_OccAllocator<T>(theAlloc),
0036                                                                          std::forward<Args>(theArgs)...);
0037   }
0038 
0039   template< class T, class... Args >
0040   std::shared_ptr<T> make_oshared(const NCollection_OccAllocator<T>& theAlloc,
0041                                   Args&&... theArgs)
0042   {
0043     return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(theAlloc,
0044                                                                          std::forward<Args>(theArgs)...);
0045   }
0046 
0047   template< class T, class... Args >
0048   std::shared_ptr<T> make_oshared(NCollection_OccAllocator<T>&& theAlloc,
0049                                   Args&&... theArgs)
0050   {
0051     return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(std::forward<NCollection_OccAllocator<T>(>theAlloc),
0052                                                                          std::forward<Args>(theArgs)...);
0053   }
0054 
0055   template <typename T, class... Args>
0056   std::unique_ptr<T> make_unique(Args&&... theArgs)
0057   {
0058     return std::unique_ptr<T>(new T(std::forward<Args>(theArgs)...));
0059   }
0060 }
0061 
0062 #endif