Boost C++ Libraries: Ticket #87: function to get the size of a array https://svn.boost.org/trac10/ticket/87 <pre class="wiki">why not add a function which can get the size of a array? just like this #include &lt;boost/type_traits.hpp&gt; template &lt;bool IS_CLASS&gt; struct SizeOfArrayHelper; template &lt;&gt; struct SizeOfArrayHelper&lt;false&gt; { template&lt;typename T&gt; static inline int SizeOfArray(const T&amp; array) { BOOST_STATIC_ASSERT(boost::is_array&lt;T&gt;::value); return sizeof(array) / sizeof(array[0]); } static inline int SizeOfArray(char *str) { return strlen(str); } static inline int SizeOfArray(const char *str) { return strlen(str); } }; template &lt;&gt; struct SizeOfArrayHelper&lt;true&gt; { template&lt;typename T&gt; static inline int SizeOfArray(const T&amp; array) { BOOST_STATIC_ASSERT(boost::is_class&lt;T&gt;::value); return array.size(); } }; template &lt;typename T&gt; inline int SizeOfArray(const T&amp; array) { return SizeOfArrayHelper&lt;boost::is_class&lt;T&gt;::value&gt;::SizeOfArr ay(array); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/87 Trac 1.4.3 nobody Mon, 07 Oct 2002 19:01:01 GMT <link>https://svn.boost.org/trac10/ticket/87#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/87#comment:1</guid> <description> <pre class="wiki">Logged In: NO ----------------- what's wrong with boost::array&lt;&gt;? Thorsten Ottosen, nesotto@cs.auc.dk </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Tue, 10 Feb 2009 03:23:10 GMT</pubDate> <title>status, resolution changed; severity set https://svn.boost.org/trac10/ticket/87#comment:2 https://svn.boost.org/trac10/ticket/87#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">fixed</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Showstopper</span> </li> </ul> <p> The Range library provides boost::size. </p> <p> <a href="http://www.boost.org/libs/range/doc/boost_range.html#size">http://www.boost.org/libs/range/doc/boost_range.html#size</a> </p> Ticket