Metall  v0.29
A persistent memory allocator for data-centric analytics
string.cpp

This is an example of how to use the STL string with Metall.

// Copyright 2019 Lawrence Livermore National Security, LLC and other Metall
// Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
#include <iostream>
#include <boost/container/string.hpp>
#include <string>
// String with Metall
using persistent_string =
boost::container::basic_string<char, std::char_traits<char>,
int main() {
{
metall::manager manager(metall::create_only, "/tmp/datastore");
auto pstr = manager.construct<persistent_string>("mystring")(
"Hello, World!", manager.get_allocator<>());
std::cout << *pstr << std::endl;
}
{
metall::manager manager(metall::open_only, "/tmp/datastore");
auto pstr = manager.find<persistent_string>("mystring").first;
std::cout << *pstr << std::endl;
}
return 0;
}
A generalized Metall manager class.
Definition: basic_manager.hpp:40
A STL compatible allocator.
Definition: stl_allocator.hpp:34
int main()
Definition: jgraph.cpp:24
basic_manager<> manager
Default Metall manager class which is an alias of basic_manager with the default template parameters.
Definition: metall.hpp:34