/src/gdal/port/cpl_noncopyablevector.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /******************************************************************************  | 
2  |  |  *  | 
3  |  |  * Project:  CPL  | 
4  |  |  * Purpose:  Implementation of a std::vector<> without copy capabilities  | 
5  |  |  * Author:   Even Rouault <even dot rouault at spatialys.com>  | 
6  |  |  *  | 
7  |  |  ******************************************************************************  | 
8  |  |  * Copyright (c) 2022, Even Rouault <even dot rouault at spatialys.com>  | 
9  |  |  *  | 
10  |  |  * SPDX-License-Identifier: MIT  | 
11  |  |  ****************************************************************************/  | 
12  |  |  | 
13  |  | #ifndef CPL_NONCOPYABLEVECOTR_H_INCLUDED  | 
14  |  | #define CPL_NONCOPYABLEVECOTR_H_INCLUDED  | 
15  |  |  | 
16  |  | #include <vector>  | 
17  |  |  | 
18  |  | namespace cpl  | 
19  |  | { | 
20  |  |  | 
21  |  | /** Derived class of std::vector<> without copy capabilities */  | 
22  |  | template <class T> struct NonCopyableVector : public std::vector<T>  | 
23  |  | { | 
24  |  |     /** Constructor  | 
25  |  |      * @param siz Initial size of vector.  | 
26  |  |      */  | 
27  | 2.28k  |     explicit inline NonCopyableVector(size_t siz = 0) : std::vector<T>(siz)  | 
28  | 2.28k  |     { | 
29  | 2.28k  |     }  | 
30  |  |  | 
31  |  |     /** Move constructor */  | 
32  | 0  |     NonCopyableVector(NonCopyableVector &&) = default;  | 
33  |  |  | 
34  |  |     /** Move assignment operator */  | 
35  | 0  |     NonCopyableVector &operator=(NonCopyableVector &&) = default;  | 
36  |  |  | 
37  |  |   private:  | 
38  |  |     NonCopyableVector(const NonCopyableVector &) = delete;  | 
39  |  |     NonCopyableVector &operator=(const NonCopyableVector &) = delete;  | 
40  |  | };  | 
41  |  |  | 
42  |  | }  // namespace cpl  | 
43  |  |  | 
44  |  | #endif  // CPL_NONCOPYABLEVECOTR_H_INCLUDED  |