diff --git a/bin/main.cpp b/bin/main.cpp index 65c21ce..7f5b6c2 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -21,4 +21,10 @@ int main(int argc, char *argv[]) hack::container::v_multiset(v, "asdf", "qwer", "zcv"); for(const auto& c : v) std::cout << c << std::endl; } + + {// ex: s_multiset + std::set s; + hack::container::s_multiset(s, 1, 2, 3, 3, 2, 1); + for(const auto& c : s) std::cout << c << std::endl; + } } diff --git a/src/container/container.hpp b/src/container/container.hpp index e88e14f..92282de 100644 --- a/src/container/container.hpp +++ b/src/container/container.hpp @@ -1,14 +1,21 @@ #pragma once #include +#include namespace hack::container { template void v_multiset(Range& r, Args... args) { - std::size_t t = sizeof... (args); + constexpr std::size_t t = sizeof... (args); r.reserve(t); (r.emplace_back(std::forward(args)), ...); } + + template + void s_multiset(Range& r, Args... args) + { + (r.insert(args), ...); + } } diff --git a/src/string/string.cpp b/src/string/string.cpp index b7c94d2..37f9aa6 100644 --- a/src/string/string.cpp +++ b/src/string/string.cpp @@ -1,5 +1,7 @@ #include "string.hpp" +#include + namespace hack::string { v_str split_str(const std::string& str, char t) @@ -15,9 +17,7 @@ namespace hack::string begin = ++end; end = str.find_first_of(t, begin); } - v.emplace_back(str.substr(begin)); - return v; } }