Note that there are some explanatory texts on larger screens.

plurals
  1. POIs const int[2] trivially copyable?
    primarykey
    data
    text
    <p>I have a templated member function which looks somewhat like the following:</p> <pre><code>template &lt;typename T&gt; int SendData( const T&amp; tDataBuffer ) const { static_assert( std::is_trivially_copyable&lt;T&gt;::value, "The object type must be trivially copyable" ); // Send the data bitwise ... } </code></pre> <p>I then call this function in a manner like the following:</p> <pre><code>const int iArray[2] = {1, 2}; int iResult = pSocket-&gt;SendData( iArray ); </code></pre> <p>When I compile this with Visual Studio 2012, I get no error message and the functionality of the program is how I would expect (i.e. the data is sent bitwise), however, when compiling with the newest version of the compiler, Visual Studio 2013, the static assert fails, the compiler issuing me the statement:</p> <pre><code>1&gt;c:\...\sockets.h(298): error C2338: The object type must be trivially copyable 1&gt; c:\...\test.cpp(974) : see reference to function template instantiation 'int CBaseSocket::SendData&lt;const int[2]&gt;(T (&amp;)) const' being compiled 1&gt; with 1&gt; [ 1&gt; T=const int [2] 1&gt; ] </code></pre> <p>So which version of the compiler is standards-conformant, should <code>const int[2]</code> be trivially copyable or not?</p> <hr> <p>Edit: This is a bug with Visual Studio 2013; here is the <a href="https://connect.microsoft.com/VisualStudio/feedback/details/806233/std-is-trivially-copyable-const-int-n-and-std-is-trivially-copyable-int-n-incorrect" rel="nofollow">Microsoft Connect report</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload