OTest2
A C++ testing framework
include
otest2
utils.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018 Ondrej Starek
3
*
4
* This file is part of OTest2.
5
*
6
* OTest2 is free software: you can redistribute it and/or modify it under
7
* the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License,
9
* or (at your option) any later version.
10
*
11
* OTest2 is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
* License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
#ifndef OTest2__INCLUDE_OTEST2_UTILS_H_
20
#define OTest2__INCLUDE_OTEST2_UTILS_H_
21
22
#include <memory>
23
#include <type_traits>
24
#include <utility>
25
26
namespace
OTest2
{
27
33
template
<
typename
T_>
34
void
odelete
(
35
T_*& object_) {
36
delete
object_;
37
object_ =
nullptr
;
38
}
39
43
template
<
typename
Type_,
typename
... Args_>
44
std::unique_ptr<Type_>
make_unique
(
45
Args_&&... args_) {
46
return
std::unique_ptr<Type_>(
new
Type_(std::forward<Args_>(args_)...));
47
}
48
49
}
/* -- namespace OTest2 */
50
51
#endif
/* OTest2__INCLUDE_OTEST2_UTILS_H_ */
OTest2::make_unique
std::unique_ptr< Type_ > make_unique(Args_ &&... args_)
Replacement of the unique_ptr function missing in C++11.
Definition:
utils.h:44
OTest2
Definition:
assertbean.h:25
OTest2::odelete
void odelete(T_ *&object_)
Delete a pointer and set it invalid.
Definition:
utils.h:34
Generated by
1.8.17