Commit 4d973371 authored by Tom Niget's avatar Tom Niget

Add forwarding constructors to PyDict and PyStr

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