Implement Property Tree Put/Get for std::size_t

This replaces the original specialisations for "bare" size_t from
the <stddef.h> header.

While here, also reorder the specialisations to match declaration
order in the header.
This commit is contained in:
Bård Skaflestad committed 2025-01-29 13:48:31 +01:00
1 parent 9fb46ab420
commit 999f98e281
2 files changed
+26 -9

No files matched your search

+17
View File
@@ -36,9 +36,11 @@
#include <opm/common/utility/FileSystem.hpp>
#include <cstddef>
#include <filesystem>
#include <fstream>
#include <ios>
#include <limits>
#include <stdexcept>
#include <string>
#include <string_view>
@@ -88,6 +90,21 @@ BOOST_AUTO_TEST_CASE(Top_Node_Only)
}
}
BOOST_AUTO_TEST_CASE(Size_T)
{
auto t = Opm::PropertyTree{};
t.put("s.ramanujan", std::size_t{1729});
BOOST_CHECK_EQUAL(t.get<std::size_t>("s.ramanujan"), std::size_t{1729});
t.put("m", static_cast<std::size_t>(-1));
BOOST_CHECK_EQUAL(t.get<std::size_t>("m"), std::numeric_limits<std::size_t>::max());
// Conversion: int -> std::size_t
t.put("n", -1);
BOOST_CHECK_EQUAL(t.get<std::size_t>("n"), std::numeric_limits<std::size_t>::max());
}
BOOST_AUTO_TEST_CASE(Missing_Keys)
{
auto t = Opm::PropertyTree{};