toml::literals namespace inline

Convenience literal operators for working with toml++.

This namespace exists so you can safely hoist the toml++ literal operators into another scope without dragging in everything from the toml namespace:

#include <toml++/toml.h>
using namespace toml::literals;

int main()
{
    toml::table tbl = "vals = [1, 2, 3]"_toml;

    // ... do stuff with the table generated by the "_toml" literal ...

    return 0;
}

Functions

auto operator""_toml(const char* str, size_t len) →  parse_result
Parses TOML data from a string literal.
auto operator""_toml(const char8_t* str, size_t len) →  parse_result
Parses TOML data from a UTF-8 string literal.

Function documentation

parse_result toml::literals::operator""_toml(const char* str, size_t len)

Parses TOML data from a string literal.

Parameters
str The string data. Must be valid UTF-8.
len The string length.
Returns With exceptions: A toml::table. Without exceptions: A toml::parse_result.
using namespace toml::literals;

auto tbl = "a = 3"_toml;
std::cout << tbl["a"] << "\n";
3

parse_result toml::literals::operator""_toml(const char8_t* str, size_t len)

Parses TOML data from a UTF-8 string literal.

Parameters
str The string data. Must be valid UTF-8.
len The string length.
Returns With exceptions: A toml::table. Without exceptions: A toml::parse_result.
using namespace toml::literals;

auto tbl = u8"a = 3"_toml;
std::cout << tbl["a"] << "\n";
3