Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38a6db7

Browse files
author
Davide Faconti
committed
back to c++11
1 parent 59d1cb9 commit 38a6db7

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.8.12) # version on Ubuntu Trusty
22
project(behaviortree_cpp_v3)
33

44
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
5-
set(CMAKE_CXX_STANDARD 14)
5+
set(CMAKE_CXX_STANDARD 11)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
else()
8-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
99
endif()
1010

1111
if(MSVC)

include/behaviortree_cpp/basic_types.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#include <typeinfo>
1010
#include <functional>
1111
#include <chrono>
12+
#include <memory>
1213
#include "behaviortree_cpp/utils/string_view.hpp"
1314
#include "behaviortree_cpp/utils/safe_any.hpp"
1415
#include "behaviortree_cpp/exceptions.h"
1516
#include "behaviortree_cpp/utils/expected.hpp"
17+
#include "behaviortree_cpp/utils/make_unique.hpp"
1618

1719
namespace BT
1820
{
@@ -336,9 +338,6 @@ PortsList getProvidedPorts(enable_if_not< has_static_method_providedPorts<T> > =
336338
typedef std::chrono::high_resolution_clock::time_point TimePoint;
337339
typedef std::chrono::high_resolution_clock::duration Duration;
338340

339-
340-
341-
342341
} // end namespace
343342

344343

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
3+
#include <memory>
4+
5+
// https://en.cppreference.com/w/cpp/feature_test
6+
#if not __has_cpp_attribute(__cpp_lib_make_unique)
7+
8+
//The compiler doesn't provide it, so implement it ourselves.
9+
10+
#include <cstddef>
11+
#include <memory>
12+
#include <type_traits>
13+
#include <utility>
14+
15+
namespace std {
16+
17+
template<class _Ty> struct _Unique_if {
18+
typedef unique_ptr<_Ty> _Single_object;
19+
};
20+
21+
template<class _Ty> struct _Unique_if<_Ty[]> {
22+
typedef unique_ptr<_Ty[]> _Unknown_bound;
23+
};
24+
25+
template<class _Ty, size_t N> struct _Unique_if<_Ty[N]> {
26+
typedef void _Known_bound;
27+
};
28+
29+
template<class _Ty, class... Args>
30+
typename _Unique_if<_Ty>::_Single_object
31+
make_unique(Args&&... args) {
32+
return unique_ptr<_Ty>(new _Ty(std::forward<Args>(args)...));
33+
}
34+
35+
template<class _Ty>
36+
typename _Unique_if<_Ty>::_Unknown_bound
37+
make_unique(size_t n) {
38+
typedef typename remove_extent<_Ty>::type U;
39+
return unique_ptr<_Ty>(new U[n]());
40+
}
41+
42+
43+
} // namespace std
44+
45+
#endif // !COMPILER_SUPPORTS_MAKE_UNIQUE
46+

0 commit comments

Comments
 (0)