Issue #100 remove auto_ptr and c++03 support.

Problem:
auto_ptr is deprecated.

Solution:
use unique_ptr which is only available in c++11 and newer.
Also fix how unit tests are run as part of the build to keep them from being
deleted when they fail.

Testing:
Unit tests on linux run.
This commit is contained in:
Dixon, Scott
2018-06-26 20:56:53 -07:00
parent dfcdf22eda
commit 4750a50099
15 changed files with 35 additions and 58 deletions
+1 -3
View File
@@ -5,8 +5,6 @@
#pragma once
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -217,7 +215,7 @@ struct TestNetwork
{ }
};
std::auto_ptr<NodeEnvironment> nodes[NumNodes];
std::unique_ptr<NodeEnvironment> nodes[NumNodes];
TestNetwork(uavcan::uint8_t first_node_id = 1)
{
@@ -18,7 +18,7 @@ using uavcan::DefaultDataTypeRegistrator;
using uavcan::MonotonicDuration;
template <typename DataType>
static bool validateDataTypeInfoResponse(const std::auto_ptr<ServiceCallResultCollector<GetDataTypeInfo>::Result>& resp,
static bool validateDataTypeInfoResponse(const std::unique_ptr<ServiceCallResultCollector<GetDataTypeInfo>::Result>& resp,
unsigned flags)
{
if (!resp.get())
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -57,8 +55,8 @@ TEST(dynamic_node_id_server_RaftCore, Basic)
InterlinkedTestNodesWithSysClock nodes;
std::auto_ptr<RaftCore> raft_a(new RaftCore(nodes.a, storage_a, tracer_a, commit_handler_a));
std::auto_ptr<RaftCore> raft_b(new RaftCore(nodes.b, storage_b, tracer_b, commit_handler_b));
std::unique_ptr<RaftCore> raft_a(new RaftCore(nodes.a, storage_a, tracer_a, commit_handler_a));
std::unique_ptr<RaftCore> raft_b(new RaftCore(nodes.b, storage_b, tracer_b, commit_handler_b));
/*
* Initialization
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -107,7 +107,7 @@ TEST(FirmwareUpdateTrigger, Basic)
uavcan::FirmwareUpdateTrigger trigger(nodes.a, checker);
std::cout << "sizeof(uavcan::FirmwareUpdateTrigger): " << sizeof(uavcan::FirmwareUpdateTrigger) << std::endl;
std::auto_ptr<uavcan::NodeStatusProvider> provider(new uavcan::NodeStatusProvider(nodes.b)); // Other node
std::unique_ptr<uavcan::NodeStatusProvider> provider(new uavcan::NodeStatusProvider(nodes.b)); // Other node
/*
* Initializing
@@ -235,10 +235,10 @@ TEST(FirmwareUpdateTrigger, MultiNode)
uavcan::FirmwareUpdateTrigger trigger(nodes[0], checker);
// The client nodes
std::auto_ptr<uavcan::NodeStatusProvider> provider_a(new uavcan::NodeStatusProvider(nodes[1]));
std::auto_ptr<uavcan::NodeStatusProvider> provider_b(new uavcan::NodeStatusProvider(nodes[2]));
std::auto_ptr<uavcan::NodeStatusProvider> provider_c(new uavcan::NodeStatusProvider(nodes[3]));
std::auto_ptr<uavcan::NodeStatusProvider> provider_d(new uavcan::NodeStatusProvider(nodes[4]));
std::unique_ptr<uavcan::NodeStatusProvider> provider_a(new uavcan::NodeStatusProvider(nodes[1]));
std::unique_ptr<uavcan::NodeStatusProvider> provider_b(new uavcan::NodeStatusProvider(nodes[2]));
std::unique_ptr<uavcan::NodeStatusProvider> provider_c(new uavcan::NodeStatusProvider(nodes[3]));
std::unique_ptr<uavcan::NodeStatusProvider> provider_d(new uavcan::NodeStatusProvider(nodes[4]));
uavcan::protocol::HardwareVersion hwver;
+2 -2
View File
@@ -20,7 +20,7 @@ class SubscriptionCollector : uavcan::Noncopyable
}
public:
std::auto_ptr<DataType> msg;
std::unique_ptr<DataType> msg;
typedef uavcan::MethodBinder<SubscriptionCollector*,
void (SubscriptionCollector::*)(const DataType&)> Binder;
@@ -85,7 +85,7 @@ private:
}
public:
std::auto_ptr<Result> result;
std::unique_ptr<Result> result;
typedef uavcan::MethodBinder<ServiceCallResultCollector*,
void (ServiceCallResultCollector::*)(const uavcan::ServiceCallResult<DataType>&)>
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -27,7 +25,7 @@ static void publishNodeStatus(PairableCanDriver& can, uavcan::NodeID node_id,
struct NodeInfoListener : public uavcan::INodeInfoListener
{
std::auto_ptr<uavcan::protocol::GetNodeInfo::Response> last_node_info;
std::unique_ptr<uavcan::protocol::GetNodeInfo::Response> last_node_info;
uavcan::NodeID last_node_id;
unsigned status_message_cnt;
unsigned status_change_cnt;
@@ -82,7 +80,7 @@ TEST(NodeInfoRetriever, Basic)
std::cout << "sizeof(uavcan::ServiceClient<uavcan::protocol::GetNodeInfo>): "
<< sizeof(uavcan::ServiceClient<uavcan::protocol::GetNodeInfo>) << std::endl;
std::auto_ptr<uavcan::NodeStatusProvider> provider(new uavcan::NodeStatusProvider(nodes.b));
std::unique_ptr<uavcan::NodeStatusProvider> provider(new uavcan::NodeStatusProvider(nodes.b));
NodeInfoListener listener;
+1 -1
View File
@@ -84,7 +84,7 @@ TEST(Dispatcher, Reception)
makeDataType(uavcan::DataTypeKindService, 1)
};
typedef std::auto_ptr<TestListener> TestListenerPtr;
typedef std::unique_ptr<TestListener> TestListenerPtr;
static const int MaxBufSize = 512;
static const int NumSubscribers = 6;
TestListenerPtr subscribers[NumSubscribers] =
+1 -3
View File
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -238,7 +236,7 @@ TEST(TransferBufferManager, Basic)
static const int POOL_BLOCKS = 100;
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
std::auto_ptr<TransferBufferManager> mgr(new TransferBufferManager(MGR_MAX_BUFFER_SIZE, pool));
std::unique_ptr<TransferBufferManager> mgr(new TransferBufferManager(MGR_MAX_BUFFER_SIZE, pool));
// Empty
ASSERT_FALSE(mgr->access(TransferBufferManagerKey(0, uavcan::TransferTypeMessageBroadcast)));
+2 -4
View File
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -59,7 +57,7 @@ TEST(Map, Basic)
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
typedef Map<std::string, std::string> MapType;
std::auto_ptr<MapType> map(new MapType(pool));
std::unique_ptr<MapType> map(new MapType(pool));
// Empty
ASSERT_FALSE(map->access("hi"));
@@ -198,7 +196,7 @@ TEST(Map, PrimitiveKey)
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
typedef Map<short, short> MapType;
std::auto_ptr<MapType> map(new MapType(pool));
std::unique_ptr<MapType> map(new MapType(pool));
// Empty
ASSERT_FALSE(map->access(1));
+3 -5
View File
@@ -3,8 +3,6 @@
*/
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
@@ -78,7 +76,7 @@ TEST(Multiset, Basic)
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
typedef Multiset<std::string> MultisetType;
std::auto_ptr<MultisetType> mset(new MultisetType(pool));
std::unique_ptr<MultisetType> mset(new MultisetType(pool));
typedef SummationOperator<std::string> StringConcatenationOperator;
@@ -199,7 +197,7 @@ TEST(Multiset, PrimitiveKey)
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
typedef Multiset<int> MultisetType;
std::auto_ptr<MultisetType> mset(new MultisetType(pool));
std::unique_ptr<MultisetType> mset(new MultisetType(pool));
// Empty
mset->removeFirst(8);
@@ -239,7 +237,7 @@ TEST(Multiset, NoncopyableWithCounter)
uavcan::PoolAllocator<uavcan::MemPoolBlockSize * POOL_BLOCKS, uavcan::MemPoolBlockSize> pool;
typedef Multiset<NoncopyableWithCounter> MultisetType;
std::auto_ptr<MultisetType> mset(new MultisetType(pool));
std::unique_ptr<MultisetType> mset(new MultisetType(pool));
ASSERT_EQ(0, NoncopyableWithCounter::num_objects);
ASSERT_EQ(0, mset->emplace()->value);