Files
toml11/docs/reference/get/index.html
ToruNiina 360850a8c8 Merge pull request #295 from franzpoeschel/undef-source-location
Add a way to optionally suppress usage of std::source_location b96acf96ba
2025-12-03 15:01:09 +00:00

141 lines
49 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
get.hpp
#
These are functions for extracting values from toml::value and performing type conversions if necessary.
toml::value can change the type it stores, and toml::get accommodates these types.
Technically, all functions use toml::basic_value<TC>.
However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary.
In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly.
toml::get<T>
#
Overview
#
Generally, toml::get behaves as follows:
You specify T as in toml::get<int>(v)."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/get/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="get.hpp"><meta property="og:description" content="get.hpp # These are functions for extracting values from toml::value and performing type conversions if necessary.
toml::value can change the type it stores, and toml::get accommodates these types. Technically, all functions use toml::basic_value<TC>. However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary. In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly. toml::get<T> # Overview # Generally, toml::get behaves as follows: You specify T as in toml::get<int>(v)."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>get.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/get/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/get/ title=get.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/get/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/ class=active>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
</label><strong>get.hpp</strong>
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#gethpp>get.hpp</a></li><li><a href=#tomlgett><code>toml::get&lt;T></code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#types-that-do-not-require-conversion>Types that Do Not Require Conversion</a></li><li><a href=#types-that-require-conversion>Types that Require Conversion</a></li><li><a href=#when-conversion-fails>When Conversion Fails</a></li></ul></li><li><a href=#when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code></a></li><li><a href=#when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value&lt;OtherTC></code> with a different <code>TypeConfig</code></a></li><li><a href=#when-t-is-an-integer-type>When <code>T</code> is an integer type</a></li><li><a href=#when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type</a></li><li><a href=#when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code></a></li><li><a href=#when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code></a></li><li><a href=#when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code></a></li><li><a href=#when-t-is-array-like>When <code>T</code> is array-like</a></li><li><a href=#when-t-is-stdarray>When <code>T</code> is <code>std::array</code></a></li><li><a href=#when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code></a></li><li><a href=#when-t-is-stdpair>When <code>T</code> is <code>std::pair</code></a></li><li><a href=#when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code></a></li><li><a href=#when-t-is-map-like>When <code>T</code> is map-like</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from&lt;T></code></a></li><li><a href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value&lt;TC></code></a></li></ul></li><li><a href=#tomlget_ort><code>toml::get_or&lt;T></code></a><ul><li><a href=#when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value&lt;TC></code></a></li><li><a href=#when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value&lt;TC>::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-something-else>When <code>T</code> is something else</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=gethpp>get.hpp
<a class=anchor href=#gethpp>#</a></h1><p>These are functions for extracting values from <code>toml::value</code> and performing type conversions if necessary.</p><blockquote class="book-hint info"><code>toml::value</code> can change the type it stores, and <code>toml::get</code> accommodates these types.
Technically, all functions use <code>toml::basic_value&lt;TC></code>.
However, for simplicity, we refer to it as <code>toml::value</code> in explanations unless a distinction is necessary.
In the documentation, if the template parameter <code>TC</code> changes the type, assume that types like <code>toml::value::integer_type</code> will also change accordingly.</blockquote><h1 id=tomlgett><code>toml::get&lt;T></code>
<a class=anchor href=#tomlgett>#</a></h1><h2 id=overview>Overview
<a class=anchor href=#overview>#</a></h2><p>Generally, <code>toml::get</code> behaves as follows:
You specify <code>T</code> as in <code>toml::get&lt;int>(v)</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>However, depending on the type of <code>T</code>, <code>toml::get</code> can exhibit different behaviors.</p><p>The types of <code>T</code> can be categorized into:</p><ol><li>Types that do not require conversion</li><li>Types that require conversion</li></ol><p>Detailed conditions and the specific types supported are discussed later.</p><h3 id=types-that-do-not-require-conversion>Types that Do Not Require Conversion
<a class=anchor href=#types-that-do-not-require-conversion>#</a></h3><p>No conversion is needed if the provided <code>toml::value</code> is already storing the desired type. For instance, since <code>toml::value::integer_type</code> is an alias for <code>std::int64_t</code>, <code>toml::get&lt;std::int64_t>(v)</code> requires no conversion. In this case, <code>toml::get</code> retrieves the <code>integer</code> value from <code>toml::value</code> and returns a reference to it.</p><p>If the provided <code>toml::value</code> is a mutable reference (<code>&</code>), the returned value is also a mutable reference (<code>&</code>). If it is an immutable reference (<code>const&</code>), the returned value will also be an immutable reference (<code>const&</code>). Returning a mutable reference allows you to overwrite the value stored in <code>toml::value</code> through that reference.</p><h3 id=types-that-require-conversion>Types that Require Conversion
<a class=anchor href=#types-that-require-conversion>#</a></h3><p>Types other than the ones mentioned above require conversion. For example, since <code>toml::value::integer_type</code> is an alias for <code>std::int64_t</code>, <code>toml::get&lt;std::size_t>(toml::value&)</code> requires conversion. In this case, <code>toml::get</code> retrieves the <code>integer</code> value from <code>toml::value</code> and casts it to return the appropriate type.</p><p>toml11 supports not only simple casts but also complex type conversions like converting from <code>toml::array</code> to <code>std::tuple&lt;int, double, std::string></code>, <code>std::array&lt;double, 4></code>, or from <code>toml::table</code> to <code>std::map&lt;std::string, int></code>. For specifics, refer to the subsequent sections.</p><h3 id=when-conversion-fails>When Conversion Fails
<a class=anchor href=#when-conversion-fails>#</a></h3><p>Sometimes, the expected type conversion cannot be performed. For example, applying <code>toml::get&lt;int>(v)</code> to a <code>toml::value</code> that holds a <code>table</code>.</p><p>In such cases, an attempt to convert to the type most similar to the desired type (in this case, <code>int</code> using <code>as_integer</code>) fails, and a <code>toml::type_error</code> is thrown.</p><p>When parsing from a file, an error message similar to the following is output:</p><pre tabindex=0><code>terminate called after throwing an instance of &#39;toml::type_error&#39;
what(): toml::value::as_integer(): bad_cast to integer
--&gt; input.toml
|
6 | [fruit]
| ^^^^^^^-- the actual type is table
</code></pre><h2 id=when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code>
<a class=anchor href=#when-t-is-identical-to-tomlvalue>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T<span style=color:#f92672>&amp;</span> get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&amp;</span> get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same&lt;T, basic_value&lt;TC>></code> is satisfied.</li></ul><p>Since this involves retrieving <code>toml::value</code> from <code>toml::value</code>, no conversion is performed, and the value is returned as is. This exists solely to generalize the implementation of other functions.</p><p>This does not fail.</p><h2 id=when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code>
<a class=anchor href=#when-t-is-one-of-tomlvaluesome_type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T<span style=color:#f92672>&amp;</span> get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&amp;</span> get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> must be the same as one of the types that <code>toml::value</code> can store (e.g., <code>toml::value::boolean_type</code>).</li></ul><p>If <code>toml::value</code> is storing a type that matches the specified type in <code>toml::get&lt;T></code>, such as <code>toml::value::integer_type</code>, no type conversion is needed, and a reference can be returned.</p><p>If a different type is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value&lt;OtherTC></code> with a different <code>TypeConfig</code>
<a class=anchor href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is not <code>toml::basic_value&lt;TC></code>.</li><li><code>T</code> is <code>toml::basic_value&lt;OtherTC></code>.</li></ul><p>When a <code>basic_value</code> that can store different types is specified, conversion is performed.</p><p>Since type conversion occurs, the returned value is a new value and not a reference.</p><p>This does not fail (except in cases like memory exhaustion).</p><h2 id=when-t-is-an-integer-type>When <code>T</code> is an integer type
<a class=anchor href=#when-t-is-an-integer-type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_integral&lt;T></code> is satisfied</li><li><code>T</code> is not <code>bool</code></li><li><code>T</code> is not <code>toml::value::integer_type</code></li></ul><p>The function assumes that <code>toml::value</code> holds an <code>integer_type</code>, retrieves its value, converts it to <code>T</code>, and returns it.</p><p>If a type other than <code>toml::value::integer_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type
<a class=anchor href=#when-t-is-a-floating-point-type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_floating_point&lt;T></code> is satisfied</li><li><code>T</code> is not <code>toml::value::floating_type</code></li></ul><p>The function assumes that <code>toml::value</code> holds a <code>floating_type</code>, retrieves its value, converts it to <code>T</code>, and returns it.</p><p>If a type other than <code>toml::value::floating_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code>
<a class=anchor href=#when-t-is-stdstring_view>#</a></h2><p>This is only available in C++17 and later.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same&lt;std::string_view, T></code> is satisfied</li></ul><p>The function assumes that <code>toml::value</code> holds a <code>string_type</code>, retrieves its value, constructs a <code>std::string_view</code> from it, and returns it.</p><p>If a type other than <code>toml::value::string_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code>
<a class=anchor href=#when-t-is-stdchronoduration>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::chrono::duration&lt;Rep, Period></code></li></ul><p>The function assumes that <code>toml::value</code> holds a <code>local_time</code>, retrieves its value, converts it to <code>std::chrono::duration</code>, and returns it.</p><p>If a type other than <code>toml::value::local_time</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code>
<a class=anchor href=#when-t-is-stdchronosystem_clocktime_point>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same&lt;T, std::chrono::system_clock::time_point></code> is satisfied</li></ul><p>If the <code>toml::value</code> holds a <code>local_date</code>, <code>local_datetime</code>, or <code>offset_datetime</code>, this function retrieves the value and converts it to <code>std::chrono::system_clock::time_point</code>, returning the result.</p><p>If the value is of a type other than <code>local_date</code>, <code>local_datetime</code>, or <code>offset_datetime</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-array-like>When <code>T</code> is array-like
<a class=anchor href=#when-t-is-array-like>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>T</code> has an <code>iterator</code></li><li><code>T</code> has a <code>value_type</code></li><li><code>T</code> supports <code>push_back(x)</code></li><li><code>T</code> is not <code>toml::value::array_type</code></li><li><code>T</code> is not <code>std::string</code></li><li><code>T</code> is not <code>std::string_view</code></li><li><code>T</code> is not map-like</li><li><code>T</code> does not have <code>from_toml()</code> member function</li><li><code>toml::from&lt;T></code> is not defined</li><li>A constructor from <code>toml::basic_value&lt;TC></code> is not defined</li></ul><p>This includes types like <code>std::vector&lt;int></code> and <code>std::deque&lt;std::string></code>.</p><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to the specified container type, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdarray>When <code>T</code> is <code>std::array</code>
<a class=anchor href=#when-t-is-stdarray>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition</p><ul><li><code>T</code> is <code>std::array&lt;U, N></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to the specified container type, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain enough elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code>
<a class=anchor href=#when-t-is-stdforward_list>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::forward_list&lt;U></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to a <code>std::forward_list</code>, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdpair>When <code>T</code> is <code>std::pair</code>
<a class=anchor href=#when-t-is-stdpair>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::pair&lt;T1, T2></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to <code>std::pair&lt;T1, T2></code>, returning the result.</p><p>The <code>first</code> and <code>second</code> elements are recursively converted.</p><p>If the value is of a type other than <code>basic_value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain exactly 2 elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code>
<a class=anchor href=#when-t-is-stdtuple>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::tuple&lt;T1, T2, ... TN></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to <code>std::tuple&lt;T1, T2, ...TN></code>, returning the result.</p><p>Each element is recursively converted.</p><p>If the value is of a type other than <code>basic_value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain exactly <code>std::tuple_size&lt;T>::value</code> elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-map-like>When <code>T</code> is map-like
<a class=anchor href=#when-t-is-map-like>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>T</code> has an <code>iterator</code></li><li><code>T</code> has a <code>key_type</code></li><li><code>T</code> has a <code>value_type</code></li><li><code>T</code> has a <code>mapped_type</code></li><li><code>T</code> is not <code>toml::value::table_type</code></li><li><code>T</code> does not have a <code>from_toml()</code> member function</li><li><code>toml::from&lt;T></code> is not defined</li><li>A constructor from <code>toml::basic_value&lt;TC></code> is not defined</li></ul><p>This includes types like <code>std::map&lt;std::string, int></code> and <code>std::unordered_map&lt;std::string, float></code>.</p><p>If the <code>toml::value</code> holds a <code>table</code>, this function retrieves the value and converts it to <code>T</code>, returning the result.</p><p>Elements are recursively converted.</p><p>If the value is of a type other than <code>basic_value::table_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from&lt;T></code>
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Condition:</p><ul><li>A specialization of <code>toml::from&lt;T></code> is defined</li></ul><p>If a specialization of <code>toml::from</code> for <code>T</code> is defined, it is used for type conversion.</p><p>Ensure this does not conflict with individually supported types (<code>std::array</code>, <code>std::pair</code>, <code>std::tuple</code> etc).</p><h2 id=when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>toml::from&lt;T></code> is not defined</li><li><code>T</code> has <code>from_toml()</code> member function</li></ul><p>If <code>T</code> has a <code>from_toml(toml::basic_value&lt;TC>)</code> member function, it is used for type conversion.</p><p>If <code>toml::from&lt;T></code> is defined, it takes precedence.</p><h2 id=when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value&lt;TC></code>
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v);
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>toml::from&lt;T></code> is not defined</li><li><code>T</code> does not have <code>from_toml()</code> member function</li><li><code>T</code> has a constructor that takes <code>toml::basic_value&lt;TC></code></li></ul><p>If <code>T</code> has a constructor that takes <code>toml::basic_value&lt;TC></code>, it is used for type conversion.</p><p>If <code>toml::from&lt;T></code> or <code>T::from_toml</code> is defined, they take precedence.</p><h1 id=tomlget_ort><code>toml::get_or&lt;T></code>
<a class=anchor href=#tomlget_ort>#</a></h1><p><code>get_or</code> takes a default value for use when the conversion fails, avoiding exceptions.</p><p>The default value must be of the same type as the target type <code>T</code>.
Therefore, unlike <code>toml::get&lt;T></code>, <code>T</code> can be inferred in <code>get_or</code>.</p><h2 id=when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value&lt;TC></code>
<a class=anchor href=#when-t-is-basic_valuetc>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;</span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&amp;</span> get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> opt)
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;</span> <span style=color:#f92672>&amp;</span> get_or(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v, basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> opt)
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;</span> get_or(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;&amp;</span> v, basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;&amp;</span> opt)
</span></span></code></pre></div><p>Since the conversion target is the same <code>toml::value</code>, this never fails.</p><p>It exists solely to generalize the implementation of other functions.</p><h2 id=when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value&lt;TC>::{some_type}</code>
<a class=anchor href=#when-t-is-basic_valuetcsome_type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&amp;</span> get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v, <span style=color:#66d9ef>const</span> T<span style=color:#f92672>&amp;</span> opt) <span style=color:#66d9ef>noexcept</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T <span style=color:#f92672>&amp;</span> get_or(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v, T<span style=color:#f92672>&amp;</span> opt) <span style=color:#66d9ef>noexcept</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span>T get_or(basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;&amp;</span> v, T<span style=color:#f92672>&amp;&amp;</span> opt) <span style=color:#66d9ef>noexcept</span>
</span></span></code></pre></div><p>Performs the same conversion as <code>toml::get&lt;T></code>. If it fails, the second argument is returned.</p><h2 id=when-t-is-const-char>When <code>T</code> is <code>const char*</code>
<a class=anchor href=#when-t-is-const-char>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;::</span>string_type
</span></span><span style=display:flex><span>get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v,
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;::</span>string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> opt);
</span></span></code></pre></div><p>When <code>const char*</code> is passed, the conversion target is interpreted as <code>std::string</code>.</p><h2 id=when-t-is-something-else>When <code>T</code> is something else
<a class=anchor href=#when-t-is-something-else>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>&gt;</span>
</span></span><span style=display:flex><span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>remove_cv<span style=color:#f92672>&lt;</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>remove_reference<span style=color:#f92672>&lt;</span>T<span style=color:#f92672>&gt;::</span>type<span style=color:#f92672>&gt;::</span>type
</span></span><span style=display:flex><span>get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&lt;</span>TC<span style=color:#f92672>&gt;&amp;</span> v, T<span style=color:#f92672>&amp;&amp;</span> opt);
</span></span></code></pre></div><p>Performs the same conversion as <code>toml::get&lt;T></code>. If it fails, the second argument is returned.</p><h1 id=related>Related
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/find/>find.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/from/>from.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#gethpp>get.hpp</a></li><li><a href=#tomlgett><code>toml::get&lt;T></code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#types-that-do-not-require-conversion>Types that Do Not Require Conversion</a></li><li><a href=#types-that-require-conversion>Types that Require Conversion</a></li><li><a href=#when-conversion-fails>When Conversion Fails</a></li></ul></li><li><a href=#when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code></a></li><li><a href=#when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value&lt;OtherTC></code> with a different <code>TypeConfig</code></a></li><li><a href=#when-t-is-an-integer-type>When <code>T</code> is an integer type</a></li><li><a href=#when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type</a></li><li><a href=#when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code></a></li><li><a href=#when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code></a></li><li><a href=#when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code></a></li><li><a href=#when-t-is-array-like>When <code>T</code> is array-like</a></li><li><a href=#when-t-is-stdarray>When <code>T</code> is <code>std::array</code></a></li><li><a href=#when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code></a></li><li><a href=#when-t-is-stdpair>When <code>T</code> is <code>std::pair</code></a></li><li><a href=#when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code></a></li><li><a href=#when-t-is-map-like>When <code>T</code> is map-like</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from&lt;T></code></a></li><li><a href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value&lt;TC></code></a></li></ul></li><li><a href=#tomlget_ort><code>toml::get_or&lt;T></code></a><ul><li><a href=#when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value&lt;TC></code></a></li><li><a href=#when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value&lt;TC>::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-something-else>When <code>T</code> is something else</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>