Boost C++ Libraries: Ticket #6811: Default argument of type multi_array fails under MSVC 2010 SP1 https://svn.boost.org/trac10/ticket/6811 <p> When I write a function with the signature </p> <pre class="wiki">typedef boost::multi_array&lt;int, 3&gt; T; void bar(const T &amp;value = T()) </pre><p> and compile it with MSVC 2010 SP1 I get the following error messages </p> <pre class="wiki">E:\postdoc\boost-bug&gt;cl /EHsc /Ie:/postdoc/tools/boost_1_49_0 mar-bug.cpp Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64 Copyright (C) Microsoft Corporation. All rights reserved. mar-bug.cpp e:/postdoc/tools/boost_1_49_0\boost/multi_array/multi_array_ref.hpp(73) : error C3855: 'boost::const_multi_array_ref': template parameter 'NumDims' is incompati ble with the declaration e:/postdoc/tools/boost_1_49_0\boost/multi_array/multi_array_ref.hpp(417) : see reference to class template instantiation 'boost::const_multi_array_ref&lt;T ,NumDims,TPtr&gt;' being compiled with [ T=int, NumDims=0x03, TPtr=int * ] e:/postdoc/tools/boost_1_49_0\boost/multi_array.hpp(113) : see reference to class template instantiation 'boost::multi_array_ref&lt;T,NumDims&gt;' being compi led with [ T=int, NumDims=0x03 ] mar-bug.cpp(5) : see reference to class template instantiation 'boost::m ulti_array&lt;T,NumDims&gt;' being compiled with [ T=int, NumDims=0x03 ] </pre><p> The offending piece of code appears to be in <code>boost/multi_array/multi_array_ref.hpp</code>: </p> <pre class="wiki"> #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS // make const_multi_array_ref a friend of itself template &lt;typename,std::size_t,typename&gt; friend class const_multi_array_ref; #endif </pre><p> If I give the template arguments names then the compiler is happy (I'll attach a patch). </p> <p> I have no idea what is special about using the type as a default argument - I tried to reproduce it using simpler steps (copy constructor, default constructor, assigning a temporary to a const ref inside a function) with no luck. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6811 Trac 1.4.3 Bruce Merry <bmerry@…> Fri, 20 Apr 2012 07:48:37 GMT attachment set https://svn.boost.org/trac10/ticket/6811 https://svn.boost.org/trac10/ticket/6811 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mar-bug.cpp</span> </li> </ul> <p> Test case illustrating the bug </p> Ticket Bruce Merry <bmerry@…> Fri, 20 Apr 2012 07:49:03 GMT attachment set https://svn.boost.org/trac10/ticket/6811 https://svn.boost.org/trac10/ticket/6811 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_1_49_0-multi_array_ref.patch</span> </li> </ul> <p> Patch that fixes the problem under MSVC </p> Ticket