*this = o;
}
-inline dynamic::dynamic(dynamic&& o)
+inline dynamic::dynamic(dynamic&& o) noexcept
: type_(NULLT)
{
*this = std::move(o);
}
-inline dynamic::~dynamic() { destroy(); }
+inline dynamic::~dynamic() noexcept { destroy(); }
template<class T>
dynamic::dynamic(T t) {
return *this;
}
-inline dynamic& dynamic::operator=(dynamic&& o) {
+inline dynamic& dynamic::operator=(dynamic&& o) noexcept {
if (&o != this) {
destroy();
#define FB_X(T) new (getAddress<T>()) T(std::move(*o.getAddress<T>()))
// Return a T* to our type, or null if we're not that type.
template<class T>
-T* dynamic::get_nothrow() {
+T* dynamic::get_nothrow() noexcept {
if (type_ != TypeInfo<T>::type) {
return nullptr;
}
}
template<class T>
-T const* dynamic::get_nothrow() const {
+T const* dynamic::get_nothrow() const noexcept {
return const_cast<dynamic*>(this)->get_nothrow<T>();
}
// Return T* for where we can put a T, without type checking. (Memory
// might be uninitialized, even.)
template<class T>
-T* dynamic::getAddress() {
+T* dynamic::getAddress() noexcept {
return GetAddrImpl<T>::get(u_);
}
template<class T>
-T const* dynamic::getAddress() const {
+T const* dynamic::getAddress() const noexcept {
return const_cast<dynamic*>(this)->getAddress<T>();
}
template<class T> struct dynamic::GetAddrImpl {};
template<> struct dynamic::GetAddrImpl<void*> {
- static void** get(Data& d) { return &d.nul; }
+ static void** get(Data& d) noexcept { return &d.nul; }
};
template<> struct dynamic::GetAddrImpl<dynamic::Array> {
- static Array* get(Data& d) { return &d.array; }
+ static Array* get(Data& d) noexcept { return &d.array; }
};
template<> struct dynamic::GetAddrImpl<bool> {
- static bool* get(Data& d) { return &d.boolean; }
+ static bool* get(Data& d) noexcept { return &d.boolean; }
};
template<> struct dynamic::GetAddrImpl<int64_t> {
- static int64_t* get(Data& d) { return &d.integer; }
+ static int64_t* get(Data& d) noexcept { return &d.integer; }
};
template<> struct dynamic::GetAddrImpl<double> {
- static double* get(Data& d) { return &d.doubl; }
+ static double* get(Data& d) noexcept { return &d.doubl; }
};
template<> struct dynamic::GetAddrImpl<fbstring> {
- static fbstring* get(Data& d) { return &d.string; }
+ static fbstring* get(Data& d) noexcept { return &d.string; }
};
template<> struct dynamic::GetAddrImpl<dynamic::ObjectImpl> {
static_assert(sizeof(ObjectImpl) <= sizeof(Data::objectBuffer),
" amount of space depending on its template parameters. This is "
"weird. Make objectBuffer bigger if you want to compile dynamic.");
- static ObjectImpl* get(Data& d) {
+ static ObjectImpl* get(Data& d) noexcept {
void* data = &d.objectBuffer;
return static_cast<ObjectImpl*>(data);
}
#undef FB_X
}
-inline void dynamic::destroy() {
+inline void dynamic::destroy() noexcept {
// This short-circuit speeds up some microbenchmarks.
if (type_ == NULLT) return;
template<class Iterator> dynamic(Iterator first, Iterator last);
dynamic(dynamic const&);
- dynamic(dynamic&&);
- ~dynamic();
+ dynamic(dynamic&&) noexcept;
+ ~dynamic() noexcept;
/*
* "Deep" equality comparison. This will compare all the way down
* Basic guarantee only.
*/
dynamic& operator=(dynamic const&);
- dynamic& operator=(dynamic&&);
+ dynamic& operator=(dynamic&&) noexcept;
/*
* For simple dynamics (not arrays or objects), this prints the
template<class T> T const& get() const;
template<class T> T& get();
- template<class T> T* get_nothrow();
- template<class T> T const* get_nothrow() const;
- template<class T> T* getAddress();
- template<class T> T const* getAddress() const;
+ template<class T> T* get_nothrow() noexcept;
+ template<class T> T const* get_nothrow() const noexcept;
+ template<class T> T* getAddress() noexcept;
+ template<class T> T const* getAddress() const noexcept;
template<class T> T asImpl() const;
static char const* typeName(Type);
- void destroy();
+ void destroy() noexcept;
void print(std::ostream&) const;
void print_as_pseudo_json(std::ostream&) const; // see json.cpp