Commit fd8f5b68 authored by Tom Niget's avatar Tom Niget

Add forwarding constructors to PyDict and PyStr

parent 1efd4296
......@@ -89,10 +89,12 @@ public:
PyDict(std::unordered_map<K, V> &&m)
: _m(std::move(
std::make_shared<std::unordered_map<K, V>>(std::move(m)))) {}
PyDict(std::initializer_list<std::pair<K, V>> &&m)
PyDict(std::initializer_list<std::pair<const K, V>> &&m)
: _m(std::make_shared<std::unordered_map<K, V>>(std::move(m))) {}
PyDict() : _m(std::make_shared<std::unordered_map<K, V>>()) {}
template<typename... Args>
PyDict(Args&&... args) : _m(std::make_shared<std::unordered_map<K, V>>(std::forward<Args>(args)...)) {}
auto begin() const { return _m->begin(); }
auto end() const { return _m->end(); }
......
......@@ -18,11 +18,11 @@ using namespace std::literals;
class PyStr : public std::string {
public:
PyStr() : std::string() {}
PyStr(const char *s) : std::string(s) {}
PyStr(const std::string &s) : std::string(s) {}
PyStr(std::string &&s) : std::string(std::move(s)) {}
PyStr(size_t count, char ch) : std::string(count, ch) {}
constexpr PyStr(const char *s, size_t count) : std::string(s, count) {}
template<typename... Args>
PyStr(Args&&... args) : std::string(std::forward<Args>(args)...) {}
template <class InputIterator>
PyStr(InputIterator first, InputIterator last) : std::string(first, last) {}
......
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