-Wold-style-cast; linked list items made noncopyable

This commit is contained in:
Pavel Kirienko
2016-07-29 16:46:57 +03:00
parent 32d8851dde
commit c9ec822244
12 changed files with 48 additions and 32 deletions
+8 -4
View File
@@ -761,7 +761,8 @@ public:
* Members must be comparable via operator ==.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->size()) && sizeof((*((const R*)(0U)))[0]), bool>::Type
typename EnableIf<sizeof((reinterpret_cast<const R*>(0))->size()) &&
sizeof((*(reinterpret_cast<const R*>(0)))[0]), bool>::Type
operator==(const R& rhs) const
{
if (size() != rhs.size())
@@ -786,7 +787,8 @@ public:
* Any container with size() and [] is acceptable.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->size()) && sizeof((*((const R*)(0U)))[0]), bool>::Type
typename EnableIf<sizeof((reinterpret_cast<const R*>(0))->size()) &&
sizeof((*(reinterpret_cast<const R*>(0)))[0]), bool>::Type
isClose(const R& rhs) const
{
if (size() != rhs.size())
@@ -1001,7 +1003,8 @@ public:
* Note that matrix packing code uses @ref areClose() for comparison.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->begin()) && sizeof(((const R*)(0U))->size())>::Type
typename EnableIf<sizeof((reinterpret_cast<const R*>(0))->begin()) &&
sizeof((reinterpret_cast<const R*>(0))->size())>::Type
packSquareMatrix(const R& src_row_major)
{
if (src_row_major.size() == MaxSize)
@@ -1057,7 +1060,8 @@ public:
* Please refer to the specification to learn more about matrix packing.
*/
template <typename R>
typename EnableIf<sizeof(((const R*)(0U))->begin()) && sizeof(((const R*)(0U))->size())>::Type
typename EnableIf<sizeof((reinterpret_cast<const R*>(0))->begin()) &&
sizeof((reinterpret_cast<const R*>(0))->size())>::Type
unpackSquareMatrix(R& dst_row_major) const
{
if (dst_row_major.size() == MaxSize)
@@ -211,7 +211,9 @@ GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::registerDataT
{
return RegistrationResultFrozen;
}
static Entry entry;
{
const RegistrationResult remove_res = remove(&entry);
if (remove_res != RegistrationResultOk)
@@ -219,7 +221,11 @@ GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::registerDataT
return remove_res;
}
}
entry = Entry(DataTypeKind(Type::DataTypeKind), id, Type::getDataTypeSignature(), Type::getDataTypeFullName());
// We can't just overwrite the entry itself because it's noncopyable
entry.descriptor = DataTypeDescriptor(DataTypeKind(Type::DataTypeKind), id,
Type::getDataTypeSignature(), Type::getDataTypeFullName());
{
const RegistrationResult remove_res = remove(&entry);
if (remove_res != RegistrationResultOk)
+1 -1
View File
@@ -14,7 +14,7 @@ namespace uavcan
class UAVCAN_EXPORT Scheduler;
class UAVCAN_EXPORT DeadlineHandler : public LinkedListNode<DeadlineHandler>, Noncopyable
class UAVCAN_EXPORT DeadlineHandler : public LinkedListNode<DeadlineHandler>
{
MonotonicTime deadline_;
@@ -24,7 +24,7 @@ class UAVCAN_EXPORT Dispatcher;
/**
* Inherit this class to receive notifications about all TX CAN frames that were transmitted with the loopback flag.
*/
class UAVCAN_EXPORT LoopbackFrameListenerBase : public LinkedListNode<LoopbackFrameListenerBase>, Noncopyable
class UAVCAN_EXPORT LoopbackFrameListenerBase : public LinkedListNode<LoopbackFrameListenerBase>
{
Dispatcher& dispatcher_;
@@ -96,7 +96,7 @@ public:
/**
* Internal, refer to the transport dispatcher class.
*/
class UAVCAN_EXPORT TransferListener : public LinkedListNode<TransferListener>, Noncopyable
class UAVCAN_EXPORT TransferListener : public LinkedListNode<TransferListener>
{
const DataTypeDescriptor& data_type_;
TransferBufferManager bufmgr_;
@@ -9,6 +9,7 @@
#include <cstdlib>
#include <cassert>
#include <uavcan/build_config.hpp>
#include <uavcan/util/templates.hpp>
namespace uavcan
{
@@ -16,7 +17,7 @@ namespace uavcan
* Classes that are supposed to be linked-listed should derive this.
*/
template <typename T>
class UAVCAN_EXPORT LinkedListNode
class UAVCAN_EXPORT LinkedListNode : Noncopyable
{
T* next_;
@@ -40,7 +41,7 @@ public:
* Linked list root.
*/
template <typename T>
class UAVCAN_EXPORT LinkedListRoot
class UAVCAN_EXPORT LinkedListRoot : Noncopyable
{
T* root_;
+1 -1
View File
@@ -70,7 +70,7 @@ class UAVCAN_EXPORT Multiset : Noncopyable
};
private:
struct Chunk : LinkedListNode<Chunk>, ::uavcan::Noncopyable
struct Chunk : LinkedListNode<Chunk>
{
enum { NumItems = (MemPoolBlockSize - sizeof(LinkedListNode<Chunk>)) / sizeof(Item) };
Item items[NumItems];