<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<divclass="header">
<divclass="headertitle">
<divclass="title">stl_logging.h</div></div>
</div><!--header-->
<divclass="contents">
<ahref="stl__logging_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div>
<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div>
<divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div>
<divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div>
<divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div>
<divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div>
<divclass="line"><aname="l00030"></a><spanclass="lineno"> 30</span> <spanclass="comment">// Forward declare these two, and define them after all the container streams</span></div>
<divclass="line"><aname="l00031"></a><spanclass="lineno"> 31</span> <spanclass="comment">// operators so that we can recurse from pair -> container -> container -> pair</span></div>
<divclass="line"><aname="l00039"></a><spanclass="lineno"> 39</span> <spanclass="keywordtype">void</span><aclass="code"href="namespacegoogle.html#ae631154cd9cf09cd2b9087903915cddf">PrintSequence</a>(std::ostream& out, Iter begin, Iter end);</div>
<divclass="line"><aname="l00058"></a><spanclass="lineno"> 58</span> <spanclass="preprocessor"> template <class T1, class T2, class T3> \</span></div>
<divclass="line"><aname="l00071"></a><spanclass="lineno"> 71</span> <spanclass="preprocessor"> template <class T1, class T2, class T3, class T4> \</span></div>
<divclass="line"><aname="l00086"></a><spanclass="lineno"> 86</span> <spanclass="preprocessor"> template <class T1, class T2, class T3, class T4, class T5> \</span></div>
<divclass="line"><aname="l00108"></a><spanclass="lineno"><aclass="line"href="namespacegoogle.html#ae631154cd9cf09cd2b9087903915cddf"> 108</a></span> <spanclass="keyword">inline</span><spanclass="keywordtype">void</span><aclass="code"href="namespacegoogle.html#ae631154cd9cf09cd2b9087903915cddf">PrintSequence</a>(std::ostream& out, Iter begin, Iter end) {</div>
<divclass="line"><aname="l00109"></a><spanclass="lineno"> 109</span> <spanclass="comment">// Output at most 100 elements -- appropriate if used for logging.</span></div>
<divclass="line"><aname="l00110"></a><spanclass="lineno"> 110</span> <spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; begin != end && i < 100; ++i, ++begin) {</div>
<divclass="line"><aname="l00111"></a><spanclass="lineno"> 111</span> <spanclass="keywordflow">if</span> (i > 0) out <<<spanclass="charliteral">''</span>;</div>
<divclass="line"><aname="l00112"></a><spanclass="lineno"> 112</span>  out << *begin;</div>
<divclass="line"><aname="l00121"></a><spanclass="lineno"> 121</span> <spanclass="comment">// Note that this is technically undefined behavior! We are adding things into</span></div>
<divclass="line"><aname="l00122"></a><spanclass="lineno"> 122</span> <spanclass="comment">// the std namespace for a reason though -- we are providing new operations on</span></div>
<divclass="line"><aname="l00123"></a><spanclass="lineno"> 123</span> <spanclass="comment">// types which are themselves defined with this namespace. Without this, these</span></div>
<divclass="line"><aname="l00124"></a><spanclass="lineno"> 124</span> <spanclass="comment">// operator overloads cannot be found via ADL. If these definitions are not</span></div>
<divclass="line"><aname="l00125"></a><spanclass="lineno"> 125</span> <spanclass="comment">// found via ADL, they must be #included before they're used, which requires</span></div>
<divclass="line"><aname="l00126"></a><spanclass="lineno"> 126</span> <spanclass="comment">// this header to be included before apparently independent other headers.</span></div>
<divclass="line"><aname="l00128"></a><spanclass="lineno"> 128</span> <spanclass="comment">// For example, base/logging.h defines various template functions to implement</span></div>
<divclass="line"><aname="l00129"></a><spanclass="lineno"> 129</span> <spanclass="comment">// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.</span></div>
<divclass="line"><aname="l00130"></a><spanclass="lineno"> 130</span> <spanclass="comment">// It does so via the function template MakeCheckOpValueString:</span></div>
<divclass="line"><aname="l00135"></a><spanclass="lineno"> 135</span> <spanclass="comment">// Because 'logging.h' is included before 'stl_logging.h',</span></div>
<divclass="line"><aname="l00136"></a><spanclass="lineno"> 136</span> <spanclass="comment">// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only</span></div>
<divclass="line"><aname="l00137"></a><spanclass="lineno"> 137</span> <spanclass="comment">// find these operator definitions via ADL.</span></div>
<divclass="line"><aname="l00139"></a><spanclass="lineno"> 139</span> <spanclass="comment">// Even this solution has problems -- it may pull unintended operators into the</span></div>
<divclass="line"><aname="l00140"></a><spanclass="lineno"> 140</span> <spanclass="comment">// namespace as well, allowing them to also be found via ADL, and creating code</span></div>
<divclass="line"><aname="l00141"></a><spanclass="lineno"> 141</span> <spanclass="comment">// that only works with a particular order of includes. Long term, we need to</span></div>
<divclass="line"><aname="l00142"></a><spanclass="lineno"> 142</span> <spanclass="comment">// move all of the *definitions* into namespace std, bet we need to ensure no</span></div>
<divclass="line"><aname="l00143"></a><spanclass="lineno"> 143</span> <spanclass="comment">// one references them first. This lets us take that step. We cannot define them</span></div>
<divclass="line"><aname="l00144"></a><spanclass="lineno"> 144</span> <spanclass="comment">// in both because that would create ambiguous overloads when both are found.</span></div>
<divclass="ttc"id="anamespacegoogle_html_ae631154cd9cf09cd2b9087903915cddf"><divclass="ttname"><ahref="namespacegoogle.html#ae631154cd9cf09cd2b9087903915cddf">google::PrintSequence</a></div><divclass="ttdeci">void PrintSequence(std::ostream &out, Iter begin, Iter end)</div><divclass="ttdef"><b>Definition:</b><ahref="stl__logging_8h_source.html#l00108">stl_logging.h:108</a></div></div>
<divclass="ttc"id="astl__logging_8h_html_a682a8f845c69fb4338ae7da571464daf"><divclass="ttname"><ahref="stl__logging_8h.html#a682a8f845c69fb4338ae7da571464daf">operator<<</a></div><divclass="ttdeci">std::ostream & operator<<(std::ostream &out, const std::pair< First, Second >&p)</div><divclass="ttdef"><b>Definition:</b><ahref="stl__logging_8h_source.html#l00099">stl_logging.h:99</a></div></div>