<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Abseil on Cheat Sheet</title><link>/tags/abseil/</link><description>Recent content in Abseil on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/abseil/index.xml" rel="self" type="application/rss+xml"/><item><title>Error Handling</title><link>/programming/cpp/advanced/error-handling/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/advanced/error-handling/</guid><description>&lt;h1 id="error-handling-in-c-abseil-status-statusort--gorust-comparison"&gt;Error Handling in C++: Abseil &lt;code&gt;Status&lt;/code&gt;, &lt;code&gt;StatusOr&amp;lt;T&amp;gt;&lt;/code&gt; &amp;amp; Go/Rust Comparison&lt;a class="anchor" href="#error-handling-in-c-abseil-status-statusort--gorust-comparison"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This article explains why large-scale C++ codebases favor &lt;strong&gt;value-based error handling (Errors as Values)&lt;/strong&gt; over C++ exceptions (&lt;code&gt;try-catch&lt;/code&gt;), how to use open-source &lt;strong&gt;Abseil (&lt;code&gt;abseil-cpp&lt;/code&gt;)&lt;/strong&gt; types &lt;code&gt;absl::Status&lt;/code&gt; and &lt;code&gt;absl::StatusOr&amp;lt;T&amp;gt;&lt;/code&gt;, and how this design maps directly to &lt;strong&gt;Go&amp;rsquo;s &lt;code&gt;(T, error)&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;Rust&amp;rsquo;s &lt;code&gt;Result&amp;lt;T, E&amp;gt;&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;C++23&amp;rsquo;s &lt;code&gt;std::expected&amp;lt;T, E&amp;gt;&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-why-large-scale-c-projects-avoid-exceptions-try-catch"&gt;1. Why Large-Scale C++ Projects Avoid Exceptions (&lt;code&gt;try-catch&lt;/code&gt;)&lt;a class="anchor" href="#1-why-large-scale-c-projects-avoid-exceptions-try-catch"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although standard C++ supports &lt;code&gt;throw&lt;/code&gt; and &lt;code&gt;try-catch&lt;/code&gt;, many large production C++ codebases (following the &lt;a href="https://google.github.io/styleguide/cppguide.html#Exceptions"&gt;Google C++ Style Guide&lt;/a&gt;) disable exceptions via &lt;code&gt;-fno-exceptions&lt;/code&gt; and rely on &lt;strong&gt;explicit error return values&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Concurrency &amp; Threading</title><link>/programming/cpp/advanced/concurrency/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/advanced/concurrency/</guid><description>&lt;h1 id="c-concurrency-stdthread-vs-lightweight-fibers-channel--abseil-mutex"&gt;C++ Concurrency: &lt;code&gt;std::thread&lt;/code&gt; vs. Lightweight Fibers, &lt;code&gt;Channel&lt;/code&gt;, &amp;amp; Abseil &lt;code&gt;Mutex&lt;/code&gt;&lt;a class="anchor" href="#c-concurrency-stdthread-vs-lightweight-fibers-channel--abseil-mutex"&gt;#&lt;/a&gt;&lt;/h1&gt;

&lt;p&gt;This guide covers the architectural differences and usage patterns between &lt;strong&gt;OS kernel threads (&lt;code&gt;std::thread&lt;/code&gt; / &lt;code&gt;std::jthread&lt;/code&gt;)&lt;/strong&gt; and &lt;strong&gt;user-space lightweight threads (&lt;code&gt;thread::Fiber&lt;/code&gt;)&lt;/strong&gt;, &lt;strong&gt;CSP message passing (&lt;code&gt;thread::Channel&amp;lt;T&amp;gt;&lt;/code&gt; &amp;amp; &lt;code&gt;thread::Select&lt;/code&gt;) and how it directly inspired the Go programming language&lt;/strong&gt;, and synchronization with compile-time thread safety verification using open-source &lt;strong&gt;Abseil (&lt;code&gt;abseil-cpp&lt;/code&gt;)&lt;/strong&gt; primitives (&lt;code&gt;absl::Mutex&lt;/code&gt; and &lt;code&gt;ABSL_GUARDED_BY&lt;/code&gt;).&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-os-kernel-threads-stdthread-vs-user-space-lightweight-threads-fibers"&gt;1. OS Kernel Threads (&lt;code&gt;std::thread&lt;/code&gt;) vs. User-Space Lightweight Threads (Fibers)&lt;a class="anchor" href="#1-os-kernel-threads-stdthread-vs-user-space-lightweight-threads-fibers"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In modern high-performance servers, concurrency models generally fall into two categories: &lt;strong&gt;1:1 OS kernel threads&lt;/strong&gt; and &lt;strong&gt;M:N user-space lightweight threads (Fibers)&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Unit Testing</title><link>/programming/cpp/advanced/unit-testing/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/advanced/unit-testing/</guid><description>&lt;h1 id="unit-testing"&gt;Unit Testing&lt;a class="anchor" href="#unit-testing"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Practical guidelines for C++ unit testing with open-source &lt;a href="https://github.com/google/googletest"&gt;GoogleTest (&lt;code&gt;google/googletest&lt;/code&gt;)&lt;/a&gt; and &lt;strong&gt;Abseil (&lt;code&gt;abseil-cpp&lt;/code&gt;)&lt;/strong&gt;, covering test file namespace layout, how &lt;code&gt;TEST&lt;/code&gt; and &lt;code&gt;TEST_F&lt;/code&gt; expand under the hood, &lt;code&gt;Test Fixture&lt;/code&gt; lifecycles, and choosing between &lt;code&gt;CHECK&lt;/code&gt;, &lt;code&gt;ASSERT_*&lt;/code&gt;, and &lt;code&gt;EXPECT_*&lt;/code&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-namespace-structure-in-test-files"&gt;1. Namespace Structure in Test Files&lt;a class="anchor" href="#1-namespace-structure-in-test-files"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="1-idiomatic-layout-namespace-pkg--namespace----"&gt;1. Idiomatic Layout: &lt;code&gt;namespace &amp;lt;pkg&amp;gt; { namespace { ... } }&lt;/code&gt;&lt;a class="anchor" href="#1-idiomatic-layout-namespace-pkg--namespace----"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When &lt;code&gt;greeter.h&lt;/code&gt; and &lt;code&gt;greeter.cc&lt;/code&gt; declare symbols inside &lt;code&gt;namespace greeter&lt;/code&gt;, the corresponding &lt;code&gt;greeter_test.cc&lt;/code&gt; should open the &lt;strong&gt;same outer &lt;code&gt;namespace greeter&lt;/code&gt;&lt;/strong&gt; and wrap the test definitions inside an inner &lt;strong&gt;&lt;a href="../../programming/cpp/primer/namespaces/"&gt;anonymous namespace&lt;/a&gt; (&lt;code&gt;namespace { ... }&lt;/code&gt;)&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>