template <class... Args>
inline dynamic dynamic::array(Args&& ...args) {
- return dynamic(Array{std::forward<Args>(args)...}, PrivateTag());
+ return dynamic(Array{std::forward<Args>(args)...});
}
// This looks like a case for perfect forwarding, but our use of
new (&u_.string) std::string(std::move(s));
}
-inline dynamic::dynamic(std::initializer_list<dynamic> il)
- : dynamic(Array(std::move(il)), PrivateTag()) {}
-
-inline dynamic& dynamic::operator=(std::initializer_list<dynamic> il) {
- (*this) = dynamic(Array(std::move(il)), PrivateTag());
- return *this;
-}
-
inline dynamic::dynamic(ObjectMaker&& maker)
: type_(OBJECT)
{
//////////////////////////////////////////////////////////////////////
-inline dynamic::dynamic(Array&& r, PrivateTag) : type_(ARRAY) {
+inline dynamic::dynamic(Array&& r) : type_(ARRAY) {
new (&u_.array) Array(std::move(r));
}
#pragma once
#include <cstdint>
-#include <initializer_list>
#include <memory>
#include <ostream>
#include <string>
* d["something_else"] = dynamic::array(1, 2, 3, nullptr);
*/
private:
- struct PrivateTag {};
struct EmptyArrayTag {};
struct ObjectMaker;
/* implicit */ dynamic(ObjectMaker const&) = delete;
/* implicit */ dynamic(ObjectMaker&&);
- /*
- * Create a new array from an initializer list.
- *
- * For example:
- *
- * dynamic v = { 1, 2, 3, "foo" };
- */
- // TODO(ott, 10300209): Remove once all uses have been eradicated.
-
- FOLLY_DEPRECATED(
- "Initializer list syntax is deprecated (#10300209). Use dynamic::array.")
- /* implicit */ dynamic(std::initializer_list<dynamic> il);
- FOLLY_DEPRECATED(
- "Initializer list syntax is deprecated (#10300209). Use dynamic::array.")
- dynamic& operator=(std::initializer_list<dynamic> il);
-
/*
* Conversion constructors from most of the other types.
*/
template<class T> struct GetAddrImpl;
template<class T> struct PrintImpl;
- dynamic(Array&& array, PrivateTag);
+ explicit dynamic(Array&& array);
template<class T> T const& get() const;
template<class T> T& get();
}
static dynamic decodeTemplate(Cursor& curs) {
- std::vector<dynamic> arr;
+ dynamic arr = folly::dynamic::array;
// List of property names
if ((BserType)curs.read<int8_t>() != BserType::Array) {
auto names = decodeArray(curs);
auto size = decodeInt(curs);
- arr.reserve(size);
while (size-- > 0) {
dynamic obj = dynamic::object;
obj[name.getString()] = parseBser(curs);
}
- arr.emplace_back(std::move(obj));
+ arr.push_back(std::move(obj));
}
- return dynamic(std::move(arr));
+ return arr;
}
static dynamic parseBser(Cursor& curs) {