<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: Word Counting in C++: Parametrizing the Type of Case	</title>
	<atom:link href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Thu, 25 Oct 2018 10:43:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.4</generator>
	<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1410</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 25 Oct 2018 10:43:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1410</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1409&quot;&gt;Stefano Bellotti&lt;/a&gt;.

Ok no worries, thanks for the follow up! It was an interesting idea though.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1409">Stefano Bellotti</a>.</p>
<p>Ok no worries, thanks for the follow up! It was an interesting idea though.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stefano Bellotti		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1409</link>

		<dc:creator><![CDATA[Stefano Bellotti]]></dc:creator>
		<pubDate>Thu, 25 Oct 2018 07:26:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1409</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1406&quot;&gt;Jonathan Boccara&lt;/a&gt;.

I&#039;ve just realized that there could be issues in returning a container of string_view; in particular, when you pass a temporary to the main function then the string_view(s) will result in something like dangling pointers.
So I think my suggestion was not so good, I&#039;m sorry for that :(]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1406">Jonathan Boccara</a>.</p>
<p>I&#8217;ve just realized that there could be issues in returning a container of string_view; in particular, when you pass a temporary to the main function then the string_view(s) will result in something like dangling pointers.<br />
So I think my suggestion was not so good, I&#8217;m sorry for that 🙁</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1406</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Tue, 23 Oct 2018 21:03:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1406</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1399&quot;&gt;Stefano Bellotti&lt;/a&gt;.

Hey Stefano, glad to read you in the comments section! Hope I&#039;ll hear of you more often here :)
Yes I think it makes sense to return a container of string_view. I&#039;ll try to implement this, thanks for the suggestion.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1399">Stefano Bellotti</a>.</p>
<p>Hey Stefano, glad to read you in the comments section! Hope I&#8217;ll hear of you more often here 🙂<br />
Yes I think it makes sense to return a container of string_view. I&#8217;ll try to implement this, thanks for the suggestion.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1405</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Tue, 23 Oct 2018 21:01:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1405</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1400&quot;&gt;jft&lt;/a&gt;.

It&#039;s an interesting abstraction, and I think this leads to nice code indeed. So to implement the computation of the &lt;a href=&quot;https://www.fluentcpp.com/2018/10/23/word-counting-span/&quot;&gt;span&lt;/a&gt; (article that came out after your comment I think), we should make a separate traversal? This might not be a problem.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1400">jft</a>.</p>
<p>It&#8217;s an interesting abstraction, and I think this leads to nice code indeed. So to implement the computation of the <a href="https://www.fluentcpp.com/2018/10/23/word-counting-span/">span</a> (article that came out after your comment I think), we should make a separate traversal? This might not be a problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1404</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Tue, 23 Oct 2018 20:54:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1404</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1396&quot;&gt;Nawar Ismail&lt;/a&gt;.

I agree that getWordsFromCode should be somehow private. The only external use I make of it is for unit tests, which I have omitted for brevity in the post series. But yes I agree with you.
Very cool idea to run in on the posts. FWIW, here is the word count for this post (code snippets included):
&lt;pre&gt;&lt;code&gt;
std             &#124;        65
code            &#124;        59
the             &#124;        57
Words           &#124;        50
of              &#124;        41
is              &#124;        39
Word            &#124;        37
end             &#124;        36
words           &#124;        35
a               &#124;        35
we              &#124;        35
&lt;/code&gt;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1396">Nawar Ismail</a>.</p>
<p>I agree that getWordsFromCode should be somehow private. The only external use I make of it is for unit tests, which I have omitted for brevity in the post series. But yes I agree with you.<br />
Very cool idea to run in on the posts. FWIW, here is the word count for this post (code snippets included):</p>
<pre><code>
std             |        65
code            |        59
the             |        57
Words           |        50
of              |        41
is              |        39
Word            |        37
end             |        36
words           |        35
a               |        35
we              |        35
</code></pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1400</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Mon, 22 Oct 2018 15:01:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1400</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1398&quot;&gt;jft&lt;/a&gt;.

This can be extended by using templated functions split() in terms of 2 or 3 predicates - either delim pred and out preds or prefix, suffix and out preds. See http://coliru.stacked-crooked.com/a/297105d418051af4

This gives a rather nice ability to split like this

&lt;pre&gt;&lt;code&gt;
const string cw = &quot;ThisIsAWordInCamelCase&quot;;
const string wrdtxt = &quot;these are my words&quot;;
 
vector words;
 
split(begin(cw), end(cw), isDelimiter, isWord, [&#038;](auto f, auto l) {words.emplace_back(f, l);});
split(begin(wrdtxt), end(wrdtxt), isDelimiter, [&#038;](auto f, auto l) {words.emplace_back(f, l);});
copy(begin(words), end(words), ostream_iterator(cout, &quot;n&quot;));
&lt;/code&gt;&lt;/pre&gt;


Any thoughts?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1398">jft</a>.</p>
<p>This can be extended by using templated functions split() in terms of 2 or 3 predicates &#8211; either delim pred and out preds or prefix, suffix and out preds. See <a href="http://coliru.stacked-crooked.com/a/297105d418051af4" rel="nofollow ugc">http://coliru.stacked-crooked.com/a/297105d418051af4</a></p>
<p>This gives a rather nice ability to split like this</p>
<pre><code>
const string cw = "ThisIsAWordInCamelCase";
const string wrdtxt = "these are my words";
 
vector words;
 
split(begin(cw), end(cw), isDelimiter, isWord, [&amp;](auto f, auto l) {words.emplace_back(f, l);});
split(begin(wrdtxt), end(wrdtxt), isDelimiter, [&amp;](auto f, auto l) {words.emplace_back(f, l);});
copy(begin(words), end(words), ostream_iterator(cout, "n"));
</code></pre>
<p>Any thoughts?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stefano Bellotti		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1399</link>

		<dc:creator><![CDATA[Stefano Bellotti]]></dc:creator>
		<pubDate>Mon, 22 Oct 2018 10:30:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1399</guid>

					<description><![CDATA[Hi Jonathan, it&#039;s the first time I post a comment on your blog (btw, it&#039;s one of my favourites) and I&#039;d like to thank you for your job that I really appreciate; I always find something interesting to read here;

Back to the words counter, since the code string you&#039;re passing in to the main algorithm is immutable, what do you think about returning the result as a container of string_views? That should save both memory occupation and performance time; do you see any drawback using this approach?]]></description>
			<content:encoded><![CDATA[<p>Hi Jonathan, it&#8217;s the first time I post a comment on your blog (btw, it&#8217;s one of my favourites) and I&#8217;d like to thank you for your job that I really appreciate; I always find something interesting to read here;</p>
<p>Back to the words counter, since the code string you&#8217;re passing in to the main algorithm is immutable, what do you think about returning the result as a container of string_views? That should save both memory occupation and performance time; do you see any drawback using this approach?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1398</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Sun, 21 Oct 2018 11:48:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1398</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1396&quot;&gt;Nawar Ismail&lt;/a&gt;.

A suggestion would be to have a stl type function with an interface that takes iterators and 1 or 2 unary predicates and returns a pair of iterators to the start/end of the extracted word. Either the same predicate is used for both before and after the word to be extracted - or one predicate is for before and one for after.

See http://coliru.stacked-crooked.com/a/dfbcbec6d31f15bd for an initial example of what I&#039;m thinking. My thoughts are that having an stl-like function extract() is that, unlike split() etc, it doesn&#039;t create/return a potential unwanted vector but just a pair of iterators to start/end of the word to be extracted. These iterators can then be used as needed (to add to a vector in the example case, or to update a map etc for word count). The returned end iterator, if not the end of the actual string being processed, then becomes the start iterator for the next extraction etc.


Note in the example I&#039;ve changed the logic of isDelimiter().]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1396">Nawar Ismail</a>.</p>
<p>A suggestion would be to have a stl type function with an interface that takes iterators and 1 or 2 unary predicates and returns a pair of iterators to the start/end of the extracted word. Either the same predicate is used for both before and after the word to be extracted &#8211; or one predicate is for before and one for after.</p>
<p>See <a href="http://coliru.stacked-crooked.com/a/dfbcbec6d31f15bd" rel="nofollow ugc">http://coliru.stacked-crooked.com/a/dfbcbec6d31f15bd</a> for an initial example of what I&#8217;m thinking. My thoughts are that having an stl-like function extract() is that, unlike split() etc, it doesn&#8217;t create/return a potential unwanted vector but just a pair of iterators to start/end of the word to be extracted. These iterators can then be used as needed (to add to a vector in the example case, or to update a map etc for word count). The returned end iterator, if not the end of the actual string being processed, then becomes the start iterator for the next extraction etc.</p>
<p>Note in the example I&#8217;ve changed the logic of isDelimiter().</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nawar Ismail		</title>
		<link>https://www.fluentcpp.com/2018/10/19/word-counting-in-cpp-parametrizing-the-type-of-case/#comment-1396</link>

		<dc:creator><![CDATA[Nawar Ismail]]></dc:creator>
		<pubDate>Fri, 19 Oct 2018 14:26:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=4293#comment-1396</guid>

					<description><![CDATA[I was wondering if the &quot;getWordsFromCode&quot; function should be made &quot;private&quot; through static or an anonymous namespace. This is because that method has now become an implementation detail. Or should the user be allowed access to that as a third way to use feature, how do you decide that?

Also I think this code could be applied to any form of text (for example this article!) since the delimiters are mostly universal. And it might be interesting to see what words YOU use in these articles. This might also suggest a name change from &quot;...Code&quot; to &quot;...Text&quot;.]]></description>
			<content:encoded><![CDATA[<p>I was wondering if the &#8220;getWordsFromCode&#8221; function should be made &#8220;private&#8221; through static or an anonymous namespace. This is because that method has now become an implementation detail. Or should the user be allowed access to that as a third way to use feature, how do you decide that?</p>
<p>Also I think this code could be applied to any form of text (for example this article!) since the delimiters are mostly universal. And it might be interesting to see what words YOU use in these articles. This might also suggest a name change from &#8220;&#8230;Code&#8221; to &#8220;&#8230;Text&#8221;.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
