Boost C++ Libraries: Ticket #5207: ICL compile errors https://svn.boost.org/trac10/ticket/5207 <p> See the code for some compilation problems. I haven't checked if there are other problems with continuous domains or static bounds. </p> <pre class="wiki">#include &lt;boost/icl/interval.hpp&gt; #include &lt;boost/icl/interval_set.hpp&gt; #include &lt;boost/icl/interval_map.hpp&gt; namespace icl = ::boost::icl; void f() { icl::interval&lt; int &gt; int_interval; icl::interval_set&lt; int &gt; int_set; icl::interval_map&lt; int, int &gt; int_map; icl::interval_map&lt; int, int &gt;::element_type int_element; icl::interval_map&lt; int, int &gt;::segment_type int_segment; /// AFAICT none of the following lines compiles and they all should: icl::lower( int_interval ); icl::upper( int_interval ); icl::first( int_interval ); icl::last( int_interval ); icl::add( int_set, int_set ); icl::add( int_map, int_map ); icl::subtract( int_set, int_set ); icl::subtract( int_map, int_map ); int_set += int_interval; icl::disjoint( int_map, int_element ); icl::disjoint( int_map, int_segment ); icl::intersects( int_map, int_segment ); icl::intersects( int_map, int_element ); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5207 Trac 1.4.3 John Reid <j.reid@…> Mon, 21 Feb 2011 15:46:54 GMT <link>https://svn.boost.org/trac10/ticket/5207#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5207#comment:1</guid> <description> <p> I'm using svn revision 69120 with gcc 4.4.3 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joachim Faulhaber</dc:creator> <pubDate>Mon, 21 Feb 2011 22:49:15 GMT</pubDate> <title>status, component changed https://svn.boost.org/trac10/ticket/5207#comment:2 https://svn.boost.org/trac10/ticket/5207#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">interval</span> → <span class="trac-field-new">ICL</span> </li> </ul> Ticket Joachim Faulhaber Tue, 22 Feb 2011 07:46:08 GMT <link>https://svn.boost.org/trac10/ticket/5207#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5207#comment:3</guid> <description> <p> I am replying to your ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5207" title="#5207: Bugs: ICL compile errors (closed: fixed)">#5207</a> on the lists because I am afraid that you walked into a trap that others can fall into as well. </p> <p> In the ITL, the precursor of Boost.ICL there was a single polymorphic interval class template: itl::interval. Due to input from the list during the review I split up this "one size fit's all" template in smaller classes according to static and dynamic interval concepts. </p> <p> In order to help ITL users to have a simple transition from ITL to ICL I wrote a template icl::interval. icl::interval is a meta function that yields the right interval type dependent on the instance type e.g. : </p> <div class="wiki-code"><div class="code"><pre><span class="n">BOOST_STATIC_ASSERT</span><span class="p">((</span> <span class="n">boost</span><span class="o">::</span><span class="n">is_same</span><span class="o">&lt;</span> <span class="n">interval</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;::</span><span class="n">type</span> <span class="p">,</span> <span class="n">discrete_interval</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="o">&gt;::</span><span class="n">value</span> <span class="p">));</span> </pre></div></div><p> So ITL users could move from ITL to ICL just by appending a <code>::type</code> to all occurrences of <code>interval&lt;T&gt;</code> </p> <p> So please note that </p> <div class="wiki-code"><div class="code"><pre><span class="n">icl</span><span class="o">::</span><span class="n">interval</span><span class="o">&lt;</span><span class="n">myType</span><span class="o">&gt;</span> <span class="n">myInterval</span><span class="p">;</span> </pre></div></div><p> can <strong>not</strong> be used as an interval type in ICL functions. </p> <p> Please use </p> <div class="wiki-code"><div class="code"><pre><span class="n">icl</span><span class="o">::</span><span class="n">interval</span><span class="o">&lt;</span><span class="n">myType</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">myInterval</span><span class="p">;</span> </pre></div></div><p> or one of the specific interval types </p> <p> <code>discrete_interval, continuous_interval,</code> (dynamic borders) </p> <p> <code>closed_interval, right_open_interval,</code> <code>left_open_interval, open_interval</code> (static borders) </p> <p> e.g. <code>discrete_interval&lt;int&gt; myInterval;</code> </p> <p> See examples <a class="ext-link" href="http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/interval.html"><span class="icon">​</span>http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/interval.html</a> </p> <p> <a class="ext-link" href="http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/dynamic_interval.html"><span class="icon">​</span>http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/dynamic_interval.html</a> </p> <p> <a class="ext-link" href="http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/static_interval.html"><span class="icon">​</span>http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/examples/static_interval.html</a> </p> <p> and docs <a class="ext-link" href="http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/interface.html#boost_icl.interface.class_templates"><span class="icon">​</span>http://www.joachim-faulhaber.de/boost_icl/doc/libs/icl/doc/html/boost_icl/interface.html#boost_icl.interface.class_templates</a> </p> <p> for more detail. </p> <p> This reduces John's non compilable ICL statements in the following way: </p> <div class="wiki-code"><div class="code"><pre><span class="n">BOOST_AUTO_TEST_CASE</span><span class="p">(</span><span class="n">ticket_5207</span><span class="p">)</span> <span class="p">{</span> <span class="n">icl</span><span class="o">::</span><span class="n">interval</span><span class="o">&lt;</span> <span class="kt">int</span> <span class="o">&gt;::</span><span class="n">type</span> <span class="n">int_interval</span><span class="p">;</span> <span class="n">icl</span><span class="o">::</span><span class="n">interval_set</span><span class="o">&lt;</span> <span class="kt">int</span> <span class="o">&gt;</span> <span class="n">int_set</span><span class="p">;</span> <span class="n">icl</span><span class="o">::</span><span class="n">interval_map</span><span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">int</span> <span class="o">&gt;</span> <span class="n">int_map</span><span class="p">;</span> <span class="n">icl</span><span class="o">::</span><span class="n">interval_map</span><span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">int</span> <span class="o">&gt;::</span><span class="n">element_type</span> <span class="n">int_element</span><span class="p">;</span> <span class="n">icl</span><span class="o">::</span><span class="n">interval_map</span><span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">int</span> <span class="o">&gt;::</span><span class="n">segment_type</span> <span class="n">int_segment</span><span class="p">;</span> <span class="c1">// The next 4 lines compile</span> <span class="n">icl</span><span class="o">::</span><span class="n">lower</span><span class="p">(</span> <span class="n">int_interval</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">upper</span><span class="p">(</span> <span class="n">int_interval</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">first</span><span class="p">(</span> <span class="n">int_interval</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">last</span><span class="p">(</span> <span class="n">int_interval</span> <span class="p">);</span> <span class="c1">// The next 4 lines are *not* supposed to compile</span> <span class="c1">// according to the docs:</span> <span class="n">icl</span><span class="o">::</span><span class="n">add</span><span class="p">(</span> <span class="n">int_set</span><span class="p">,</span> <span class="n">int_set</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">add</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_map</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">subtract</span><span class="p">(</span> <span class="n">int_set</span><span class="p">,</span> <span class="n">int_set</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">subtract</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_map</span> <span class="p">);</span> <span class="n">int_set</span> <span class="o">+=</span> <span class="n">int_interval</span><span class="p">;</span> <span class="c1">// compiles</span> <span class="c1">// Here you are right, John:</span> <span class="c1">// The next 4 lines should compile according</span> <span class="c1">// to the docs, but don&#39;t</span> <span class="n">icl</span><span class="o">::</span><span class="n">disjoint</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_element</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">disjoint</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_segment</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">intersects</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_segment</span> <span class="p">);</span> <span class="n">icl</span><span class="o">::</span><span class="n">intersects</span><span class="p">(</span> <span class="n">int_map</span><span class="p">,</span> <span class="n">int_element</span> <span class="p">);</span> <span class="p">}</span> </pre></div></div><p> Thanks for using my library and helping to improve it. Joachim </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joachim Faulhaber</dc:creator> <pubDate>Tue, 22 Feb 2011 07:46:51 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5207#comment:4 https://svn.boost.org/trac10/ticket/5207#comment:4 <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-new">fixed</span> </li> </ul> Ticket