inline int64_t& dynamic::getInt() { return get<int64_t>(); }
inline bool& dynamic::getBool() { return get<bool>(); }
-inline const char* dynamic::data() const { return get<fbstring>().data(); }
-inline const char* dynamic::c_str() const { return get<fbstring>().c_str(); }
+inline const char* dynamic::data() const& { return get<fbstring>().data(); }
+inline const char* dynamic::c_str() const& { return get<fbstring>().c_str(); }
inline StringPiece dynamic::stringPiece() const { return get<fbstring>(); }
template<class T>
std::forward<V>(v))).first->second;
}
-inline dynamic* dynamic::get_ptr(dynamic const& idx) {
+inline dynamic* dynamic::get_ptr(dynamic const& idx) & {
return const_cast<dynamic*>(const_cast<dynamic const*>(this)->get_ptr(idx));
}
// Return a T* to our type, or null if we're not that type.
template<class T>
-T* dynamic::get_nothrow() noexcept {
+T* dynamic::get_nothrow() & noexcept {
if (type_ != TypeInfo<T>::type) {
return nullptr;
}
}
template<class T>
-T const* dynamic::get_nothrow() const noexcept {
+T const* dynamic::get_nothrow() const& noexcept {
return const_cast<dynamic*>(this)->get_nothrow<T>();
}
return std::move(v);
}
-const dynamic* dynamic::get_ptr(dynamic const& idx) const {
+const dynamic* dynamic::get_ptr(dynamic const& idx) const& {
if (auto* parray = get_nothrow<Array>()) {
if (!idx.isInt()) {
throw TypeError("int64", idx.type());
*
* These will throw a TypeError if the dynamic is not a string.
*/
- const char* data() const;
- const char* c_str() const;
+ const char* data() const&;
+ const char* data() && = delete;
+ const char* c_str() const&;
+ const char* c_str() && = delete;
StringPiece stringPiece() const;
/*
* Using these with dynamic objects that are not arrays or objects
* will throw a TypeError.
*/
- const dynamic* get_ptr(dynamic const&) const;
- dynamic* get_ptr(dynamic const&);
+ const dynamic* get_ptr(dynamic const&) const&;
+ dynamic* get_ptr(dynamic const&) &;
+ dynamic* get_ptr(dynamic const&) && = delete;
/*
* This works for access to both objects and arrays.
template<class T> T const& get() const;
template<class T> T& get();
- template<class T> T* get_nothrow() noexcept;
- template<class T> T const* get_nothrow() const noexcept;
+ template<class T> T* get_nothrow() & noexcept;
+ template<class T> T const* get_nothrow() const& noexcept;
+ template<class T> T* get_nothrow() && noexcept = delete;
template<class T> T* getAddress() noexcept;
template<class T> T const* getAddress() const noexcept;