Add C string bt_value ctor

This commit is contained in:
Jason Rhinelander 2020-09-01 15:10:21 -03:00
parent 8c28c52d41
commit 9467c4682c
2 changed files with 4 additions and 0 deletions

View file

@ -106,6 +106,7 @@ struct bt_value : bt_variant {
template <typename T, typename U = std::remove_reference_t<T>, std::enable_if_t<!std::is_integral_v<U> && !detail::is_tuple<U>, int> = 0>
bt_value(T&& v) : bt_variant{std::forward<T>(v)} {}
bt_value(const char* s) : bt_value{std::string_view{s}} {}
};
}

View file

@ -90,6 +90,9 @@ TEST_CASE("bt_value serialization", "[bt][serialization][bt_value]") {
std::string x_ = bt_serialize(dna);
REQUIRE( bt_serialize(dna) == "i42e" );
bt_value foo{"foo"};
REQUIRE( bt_serialize(foo) == "3:foo" );
bt_value ibig{-8'000'000'000'000'000'000LL};
bt_value ubig{10'000'000'000'000'000'000ULL};
int16_t ismall = -123;