[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [dferry] serialization: VarHeaderStorage: use std::aligned_storage for its intended purpose.
From:       Andreas Hartmetz <ahartmetz () gmail ! com>
Date:       2016-06-16 22:56:14
Message-ID: E1bDgCs-00023n-G2 () scm ! kde ! org
[Download RAW message or body]

Git commit 1f9bc85f5cc77db1766b8f38ee09d7e96c1cf0f3 by Andreas Hartmetz.
Committed on 16/06/2016 at 22:52.
Pushed by ahartmetz into branch 'master'.

VarHeaderStorage: use std::aligned_storage for its intended purpose.

It does directly what is needed here, which allows to remove some
comments. The code isn't very different.

M  +3    -6    serialization/message_p.h

http://commits.kde.org/dferry/1f9bc85f5cc77db1766b8f38ee09d7e96c1cf0f3

diff --git a/serialization/message_p.h b/serialization/message_p.h
index 1837369..1c455b6 100644
--- a/serialization/message_p.h
+++ b/serialization/message_p.h
@@ -30,6 +30,8 @@
 #include "error.h"
 #include "iconnectionclient.h"
 
+#include <type_traits>
+
 class ICompletionClient;
 
 class VarHeaderStorage {
@@ -69,12 +71,7 @@ public:
     static const int s_intHeaderCount = 2;
 
     // Uninitialized storage for strings, to avoid con/destructing strings we'd \
                never touch otherwise.
-    // Since unsigned char * is incompatible with char *, it gives better compiler \
                messages than char if
-    // there is a problem; std::string deals with char * a lot.
-
-    // the awkward position of alignas() is the only one that works with both g++ \
                and clang++...
-    unsigned char m_stringStorage alignas(std::string)
-        [sizeof(std::string[VarHeaderStorage::s_stringHeaderCount])];
+    std::aligned_storage<sizeof(std::string)>::type \
m_stringStorage[VarHeaderStorage::s_stringHeaderCount];  uint32 \
m_intHeaders[s_intHeaderCount];  uint32 m_headerPresenceBitmap = 0;
 };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic