Unverified Commit 69bb2c9f authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #768

Fix dictionary emplace with char array
parents cb4f6977 3bb24251
...@@ -290,6 +290,11 @@ private: ...@@ -290,6 +290,11 @@ private:
return std::lower_bound(from, end(), key, cmp); return std::lower_bound(from, end(), key, cmp);
} }
template <size_t N>
static inline std::string copy(const char (&str)[N]) {
return std::string{str};
}
// Copies the content of `str` into a new string. // Copies the content of `str` into a new string.
static inline std::string copy(string_view str) { static inline std::string copy(string_view str) {
return std::string{str.begin(), str.end()}; return std::string{str.begin(), str.end()};
......
...@@ -79,6 +79,13 @@ CAF_TEST(swapping) { ...@@ -79,6 +79,13 @@ CAF_TEST(swapping) {
CAF_CHECK_NOT_EQUAL(xs, zs); CAF_CHECK_NOT_EQUAL(xs, zs);
} }
CAF_TEST(emplacing) {
int_dict xs;
CAF_CHECK_EQUAL(xs.emplace("x", 1).second, true);
CAF_CHECK_EQUAL(xs.emplace("y", 2).second, true);
CAF_CHECK_EQUAL(xs.emplace("y", 3).second, false);
}
CAF_TEST(insertion) { CAF_TEST(insertion) {
int_dict xs; int_dict xs;
CAF_CHECK_EQUAL(xs.insert("a", 1).second, true); CAF_CHECK_EQUAL(xs.insert("a", 1).second, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment