Boost C++ Libraries: Ticket #3997: Can't use iterator_range as template argument in tokenizer https://svn.boost.org/trac10/ticket/3997 <p> I tried to use boost tokenizer directly with char* (instead of std::string) In order to do so, I needed convert the char* to iterator_range. I managed to do so by calling "as_literal" method. Afterwards I used iterator range as tokenizer argument and took tokenizer's iterator for token parsing. However I got compiler error that "assign" method on iterator_range object isn't defined. I think this compilation problem could easily fixed by adding to iterator_range new "assign" method: </p> <blockquote> <p> iterator_range&amp; assign(IteratorT beg, IteratorT end) </p> <blockquote> <p> { </p> <blockquote> <p> m_Begin = beg; m_End = end; #ifndef NDEBUG singular = false; #endif return *this; </p> </blockquote> <p> } </p> </blockquote> </blockquote> <p> thanks, Roman </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3997 Trac 1.4.3 Steven Watanabe Thu, 11 Mar 2010 20:54:37 GMT <link>https://svn.boost.org/trac10/ticket/3997#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3997#comment:1</guid> <description> <p> This would probably be a bad idea, since the semantics of assign for containers are significantly different from what they would be for iterator_range. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 12 Mar 2010 03:23:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3997#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3997#comment:2</guid> <description> <p> Steven, could you please elaborate on this? semantics of assign for example for string container does have such signature and since I want to use iterator_range as a container for boost::tokenizer I am forced (by tokenizer implementation) to have such assign method thanks, Roman </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 12 Mar 2010 04:28:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3997#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3997#comment:3</guid> <description> <p> Assign for containers makes a copy of all the elements. Clearly, iterator_range is not going to do this. I think it's a bad idea for iterator_range to try to mimic the mutable interface of containers, when the actual behavior is not consistent. While I appreciate that you want to use iterator_range with tokenizer, I think adding assign to iterator_range is probably the wrong solution. I think it would be better if tokenizer could be changed so that it doesn't rely on assign. </p> </description> <category>Ticket</category> </item> <item> <author>Roman Bober <roman300178@…></author> <pubDate>Fri, 12 Mar 2010 05:43:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3997#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3997#comment:4</guid> <description> <p> I see,and of course my assign method suggestion above doesn't make copy of elements, but rather "repoints" to new location by given iterators. However, I understand your point, that notion of assign for containers is different from iterator_range concept. Solution I think lies somewhere in the middle, since tokenizer takes as template argument Container and iterator_range isn't truly a container, thus there must be some way to interact between. So change to the tokenizer could be: it would take iterator_range as it's template argument as well? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Sat, 03 Apr 2010 21:30:54 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/3997#comment:5 https://svn.boost.org/trac10/ticket/3997#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Thorsten Ottosen</span> to <span class="trac-author">Neil Groves</span> </li> </ul> <p> Reassigned since this is I am maintaining Boost.Range </p> Ticket Neil Groves Wed, 07 Apr 2010 23:54:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3997#comment:6 https://svn.boost.org/trac10/ticket/3997#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The documented requirements for the Tokenizer argument are greater than those provided by the Range Concept. In particular the Tokenizer algorithm needs to be able to utilize container functions to resize / allocate etc. This is far outside of the scope of the Range Concept by design. </p> <p> Since using a container appears an easy and optimal solution I am closing this issue. </p> Ticket