MarkLogic Connect
MarkLogic Connect Client API Collection
memory.hpp
1 /*
2  * Copyright (c) MarkLogic Corporation. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  *
14  * memory.hpp
15  *
16  * Created on: 16 May 2016
17  * Author: adamfowler
18  */
19 
20 #ifndef SRC_INTERNALS_MEMORY_HPP_
21 #define SRC_INTERNALS_MEMORY_HPP_
22 
23 namespace mlclient {
24 
25 // make_unique<T>
26 /*
27  * Provides an implementation of std::make_unique - not supplied by some compilers.
28  * This function should be used for the creation of ALL std::unique_ptr objects
29  * as it guarantees the object is created correctly and consistently.
30  *
31  * Note a syntax error for the array form, and the disallowed array element form.
32  * These use variadic templates from C++14
33  */
34 template<class T, class... Types> std::unique_ptr<T> make_unique(Types&&... Args) {
35  return (std::unique_ptr<T>(new T(std::forward<Types>(Args)...)));
36 }
37 
38 // make_unique<T[]>
39 //template<class T> make_unique(size_t Size) {
40 // return (std::unique_ptr<T>(new Elem[Size]()));
41 //}
42 
43 // make_unique<T[N]> disallowed
44 //template<class T, class... Types> typename enable_if extent<T>::value != 0, <void>::type make_unique(Types&&...) = delete;
45 
46 
47 } // end namespace mlclient
48 
49 #endif /* SRC_INTERNALS_MEMORY_HPP_ */
the namespace which wraps all Core Public C++ API classes.
Definition: Connection.hpp:36