Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:21:57

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 occ::handle<NCollection_BaseAllocator>& theAlloc,
0033                                 Args&&... theArgs)
0034 {
0035   return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(
0036     NCollection_OccAllocator<T>(theAlloc),
0037     std::forward<Args>(theArgs)...);
0038 }
0039 
0040 template <class T, class... Args>
0041 std::shared_ptr<T> make_oshared(const NCollection_OccAllocator<T>& theAlloc, Args&&... theArgs)
0042 {
0043   return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(
0044     theAlloc,
0045     std::forward<Args>(theArgs)...);
0046 }
0047 
0048 template <class T, class... Args>
0049 std::shared_ptr<T> make_oshared(NCollection_OccAllocator<T>&& theAlloc, Args&&... theArgs)
0050 {
0051   return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(
0052     std::forward<NCollection_OccAllocator<T>>(theAlloc),
0053     std::forward<Args>(theArgs)...);
0054 }
0055 
0056 template <typename T, class... Args>
0057 std::unique_ptr<T> make_unique(Args&&... theArgs)
0058 {
0059   return std::unique_ptr<T>(new T(std::forward<Args>(theArgs)...));
0060 }
0061 } // namespace opencascade
0062 
0063 #endif