• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
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  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_VERIFICATION_UTIL_PANDA_OR_STD_H
17 #define PANDA_VERIFICATION_UTIL_PANDA_OR_STD_H
18 
19 #ifdef PANDA_RAPIDCHECK
20 #include <memory>
21 #else
22 #include "runtime/include/mem/panda_containers.h"
23 #include "runtime/include/mem/panda_smart_pointers.h"
24 #endif
25 
26 namespace panda::verifier {
27 
28 // Panda's allocator by default, standard allocator if Rapidcheck is enabled because it doesn't link Panda's libraries
29 #ifdef PANDA_RAPIDCHECK
30 template <typename T>
31 using MPandaAllocator = std::allocator<T>;
32 
33 template <typename T>
34 using MPandaVector = std::vector<T>;
35 
36 template <typename T>
37 using MPandaUniquePtr = std::unique_ptr<T>;
38 
39 // much simpler than trying to reproduce the full API
40 #define MMakePandaUnique std::make_unique
41 #else
42 template <typename T>
43 using MPandaAllocator = panda::mem::AllocatorAdapter<T>;
44 
45 template <typename T>
46 using MPandaVector = PandaVector<T>;
47 
48 template <typename T>
49 using MPandaUniquePtr = PandaUniquePtr<T>;
50 
51 #define MMakePandaUnique MakePandaUnique
52 #endif
53 
54 }  // namespace panda::verifier
55 
56 #endif  // PANDA_VERIFICATION_UTIL_PANDA_OR_STD_H
57