Boost C++ Libraries: Ticket #4496: xpressive::as<int>(_) does not work with wchar_t https://svn.boost.org/trac10/ticket/4496 <pre class="wiki"> using namespace boost::xpressive; std::wstring version(L"0.9.500"); int maj1(0), min1(0), build1(0); wsregex re1 = (+_d)[ref(maj1) = as&lt;int&gt;(_)] &gt;&gt; L"." &gt;&gt; (+_d)[ref(min1) = as&lt;int&gt;(_)] &gt;&gt; L"." &gt;&gt; (+_d)[ref(build1) = as&lt;int&gt;(_)]; bool v1 = regex_match(version, re1); std::wcout &lt;&lt; maj1 &lt;&lt; std::endl; // 48 must be 0 std::wcout &lt;&lt; min1 &lt;&lt; std::endl; // 57 must be 9 std::wcout &lt;&lt; build1 &lt;&lt; std::endl; // 534848 must be 500 </pre><p> The cause is </p> <pre class="wiki"> template&lt;typename T&gt; struct as { typedef T result_type; template&lt;typename Value&gt; T operator()(Value const &amp;val) const { return lexical_cast&lt;T&gt;(val); } }; </pre><p> val is sub_match type (this case) </p> <p> lexical_cast&lt;T&gt; uses stream_char&lt;T&gt; to define the widest char while there is no spec for stream_char&lt;xpressive::sub_match&gt; so lexical_cast uses char as char_type </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4496 Trac 1.4.3 anonymous Fri, 30 Jul 2010 14:03:38 GMT <link>https://svn.boost.org/trac10/ticket/4496#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4496#comment:1</guid> <description> <p> MS VC2008 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 03 Aug 2010 21:06:52 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/4496#comment:2 https://svn.boost.org/trac10/ticket/4496#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Eric Niebler Wed, 06 Oct 2010 19:02:31 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4496#comment:3 https://svn.boost.org/trac10/ticket/4496#comment:3 <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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65788" title="as() handles wide sub_match objects correctly, fixes #4496">[65788]</a>) as() handles wide sub_match objects correctly, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4496" title="#4496: Bugs: xpressive::as&lt;int&gt;(_) does not work with wchar_t (closed: fixed)">#4496</a> </p> Ticket Eric Niebler Sat, 09 Oct 2010 19:00:15 GMT <link>https://svn.boost.org/trac10/ticket/4496#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4496#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65866" title="Merged revisions 65788 via svnmerge from ...">[65866]</a>) Merged revisions 65788 via svnmerge from <a class="ext-link" href="https://svn.boost.org/svn/boost/trunk"><span class="icon">​</span>https://svn.boost.org/svn/boost/trunk</a> </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/65788" title="as() handles wide sub_match objects correctly, fixes #4496">r65788</a> | eric_niebler | 2010-10-06 12:02:04 -0700 (Wed, 06 Oct 2010) | 1 line </p> </blockquote> <p> </p> <blockquote> <p> as() handles wide sub_match objects correctly, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4496" title="#4496: Bugs: xpressive::as&lt;int&gt;(_) does not work with wchar_t (closed: fixed)">#4496</a> </p> </blockquote> <p> ........ </p> </description> <category>Ticket</category> </item> </channel> </rss>