title: Using BOOST_FOREACH with a constant intrusive list
body: <p>Consider the following code to iterate over an intrusive list using the BOOST_FOREACH macro:</p>
  
  <pre><code>#include &lt;boost/foreach.hpp&gt;
  #include &lt;boost/intrusive/list.hpp&gt;
  
  typedef boost::intrusive::list&lt;
      boost::intrusive::list_base_hook&lt;&gt; &gt; MyList;
  
  void iterate (const MyList&amp; xs) {
      BOOST_FOREACH (MyList::const_reference node, xs);
  }
  
  int main () {
      MyList xs;
      iterate (xs);
      return 0;
  }
  </code></pre>
  
  <p>Given boost version 1.48 the code fails with clang 3.2 (SVN) and gcc 4.6.3, but works with gcc 4.5.3. With non-const-qualified parameter <code>xs</code> to <code>iterate</code> the code works. With C++11 enabled all of the compilers accept the code. When using boost-1.46 both gcc versions accept the code, but clang still doesn't.</p>
  
  <p>Is the code at hand a misuse of the <code>BOOST_FOREACH</code> macro, or is the error at boosts side? Is there a workaround that is nicer than iteration with regular for-loop?</p>
  
  <p>Edit:
  I pasted the error messages to pastebin (both are very verbose) for <a href="http://pastebin.com/Cn4uw4pB" rel="nofollow">GCC</a> and <a href="http://pastebin.com/vddBw0c8" rel="nofollow">clang</a>.</p>