<?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: tee: Debug Info With Little Impact On Code	</title>
	<atom:link href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Fri, 31 Aug 2018 10:06:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: fievel		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-1258</link>

		<dc:creator><![CDATA[fievel]]></dc:creator>
		<pubDate>Fri, 31 Aug 2018 10:06:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-1258</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-573&quot;&gt;sv90&lt;/a&gt;.

Yes I adapted this very useful snippet with 
#define TEE(x) tee(__FILE__, __LINE__, #x, (x))

Now let  see if my manager agree I submit that to codebase]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-573">sv90</a>.</p>
<p>Yes I adapted this very useful snippet with<br />
#define TEE(x) tee(__FILE__, __LINE__, #x, (x))</p>
<p>Now let  see if my manager agree I submit that to codebase</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sv90		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-573</link>

		<dc:creator><![CDATA[sv90]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 13:19:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-573</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-570&quot;&gt;Jonathan Boccara&lt;/a&gt;.

In principle, one could also use the __FILE__ and __LINE__ macros to get even more informations.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-570">Jonathan Boccara</a>.</p>
<p>In principle, one could also use the __FILE__ and __LINE__ macros to get even more informations.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-571</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 13:11:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-571</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-565&quot;&gt;Gerald Squelart&lt;/a&gt;.

Good point! I worked it into the article, thanks.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-565">Gerald Squelart</a>.</p>
<p>Good point! I worked it into the article, thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-572</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 13:11:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-572</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-567&quot;&gt;Sergio Adán&lt;/a&gt;.

Didn&#039;t think about using runtime polymorphism with std::ostream here. Thanks for sharing this idea!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-567">Sergio Adán</a>.</p>
<p>Didn&#8217;t think about using runtime polymorphism with std::ostream here. Thanks for sharing this idea!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-570</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 13:07:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-570</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-568&quot;&gt;sv90&lt;/a&gt;.

Very interesting, thanks for sharing!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-568">sv90</a>.</p>
<p>Very interesting, thanks for sharing!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-569</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 13:06:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-569</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-566&quot;&gt;Luis Antonio Donoso de Dios&lt;/a&gt;.

Hey Luis, you&#039;re right, this allows to have a unique interface for const and non-const arguments.

If we pass an object to the implementation at the top then it makes a copy and returns it, which is not the purpose of a logger. And even if we change it and make it return a const reference then we can no longer pass it a non-const reference without having it constified. This is no the point of the logger either.

The forwarding reference allows to keep whatever const + l/r value semantics of the argument passed.
Hope I&#039;m making sense here :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-566">Luis Antonio Donoso de Dios</a>.</p>
<p>Hey Luis, you&#8217;re right, this allows to have a unique interface for const and non-const arguments.</p>
<p>If we pass an object to the implementation at the top then it makes a copy and returns it, which is not the purpose of a logger. And even if we change it and make it return a const reference then we can no longer pass it a non-const reference without having it constified. This is no the point of the logger either.</p>
<p>The forwarding reference allows to keep whatever const + l/r value semantics of the argument passed.<br />
Hope I&#8217;m making sense here 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sv90		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-568</link>

		<dc:creator><![CDATA[sv90]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 06:39:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-568</guid>

					<description><![CDATA[When using logging like this i like to also see the name of logged variable or expression. So I would maybe rewrite the second version as
```
namespace detail {
template 
decltype(auto) tee(const char* name, T&#038;&#038; val) noexcept {
  std::clog &#060;&#060; name &#060;&#060; &#034; = &#034; &#060;&#060; val &#060;&#060; &#039;n&#039;;
  return std::forward(val);
}
} // namespace detail

#define TEE(x) detail::tee(#x, (x))
```
One could also wrap the macro inside some kind of `#ifndef` to deactivate logging with one variable.]]></description>
			<content:encoded><![CDATA[<p>When using logging like this i like to also see the name of logged variable or expression. So I would maybe rewrite the second version as<br />
&#8220;`<br />
namespace detail {<br />
template<br />
decltype(auto) tee(const char* name, T&amp;&amp; val) noexcept {<br />
  std::clog &lt;&lt; name &lt;&lt; &quot; = &quot; &lt;&lt; val &lt;&lt; &#039;n&#039;;<br />
  return std::forward(val);<br />
}<br />
} // namespace detail</p>
<p>#define TEE(x) detail::tee(#x, (x))<br />
&#8220;`<br />
One could also wrap the macro inside some kind of `#ifndef` to deactivate logging with one variable.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sergio Adán		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-567</link>

		<dc:creator><![CDATA[Sergio Adán]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 06:15:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-567</guid>

					<description><![CDATA[I preffer to avoid templates to set up the stream. You will be unable to change the stream at runtime if it is set as a template parameter. Something like this (simplified version): https://wandbox.org/permlink/lXEMwmrRBgkQa8AU

This solution allows you to change between different output streams at runtime and even use multiple streams (with few changes) at the same time without changing anything in the code.]]></description>
			<content:encoded><![CDATA[<p>I preffer to avoid templates to set up the stream. You will be unable to change the stream at runtime if it is set as a template parameter. Something like this (simplified version): <a href="https://wandbox.org/permlink/lXEMwmrRBgkQa8AU" rel="nofollow ugc">https://wandbox.org/permlink/lXEMwmrRBgkQa8AU</a></p>
<p>This solution allows you to change between different output streams at runtime and even use multiple streams (with few changes) at the same time without changing anything in the code.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Luis Antonio Donoso de Dios		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-566</link>

		<dc:creator><![CDATA[Luis Antonio Donoso de Dios]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 04:36:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-566</guid>

					<description><![CDATA[Please, could you elaborate which cases are not covered by the first version of `tee`? Is it to do with the constness of the argument?]]></description>
			<content:encoded><![CDATA[<p>Please, could you elaborate which cases are not covered by the first version of `tee`? Is it to do with the constness of the argument?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Gerald Squelart		</title>
		<link>https://www.fluentcpp.com/2017/09/29/tee-getting-precious-debug-info-easily/#comment-565</link>

		<dc:creator><![CDATA[Gerald Squelart]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 02:21:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1649#comment-565</guid>

					<description><![CDATA[For those stuck with C++11, where `decltype(auto)` is not available, use `auto f() -&#062; return_type`, e.g.:
&lt;pre&gt;&lt;code&gt;auto tee(T&#038;&#038; value) -&#062; decltype(std::forward(value))&lt;/code&gt;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>For those stuck with C++11, where `decltype(auto)` is not available, use `auto f() -&gt; return_type`, e.g.:</p>
<pre><code>auto tee(T&amp;&amp; value) -&gt; decltype(std::forward(value))</code></pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
