X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fdynamic.cpp;h=cc1ffdea211cf590e790e4d1c22a7a722643f8d7;hb=44ce72fdb5b5dca54f799f62c2e8c7791c2e2fcc;hp=5e656c5e2d2acb0ce461942e9a88cbeefe295335;hpb=eb6bd53fde2fd971d891c06fa81f8d0e385a79a1;p=folly.git diff --git a/folly/dynamic.cpp b/folly/dynamic.cpp index 5e656c5e..cc1ffdea 100644 --- a/folly/dynamic.cpp +++ b/folly/dynamic.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,10 @@ * limitations under the License. */ -#include #include + +#include +#include #include namespace folly { @@ -206,7 +208,7 @@ const dynamic* dynamic::get_ptr(dynamic const& idx) const& { if (idx < 0 || idx >= parray->size()) { return nullptr; } - return &(*parray)[idx.asInt()]; + return &(*parray)[size_t(idx.asInt())]; } else if (auto* pobject = get_nothrow()) { auto it = pobject->find(idx); if (it == pobject->end()) { @@ -226,7 +228,7 @@ dynamic const& dynamic::at(dynamic const& idx) const& { if (idx < 0 || idx >= parray->size()) { std::__throw_out_of_range("out of range in dynamic array"); } - return (*parray)[idx.asInt()]; + return (*parray)[size_t(idx.asInt())]; } else if (auto* pobject = get_nothrow()) { auto it = pobject->find(idx); if (it == pobject->end()) { @@ -252,8 +254,7 @@ std::size_t dynamic::size() const { throw TypeError("array/object", type()); } -dynamic::const_iterator -dynamic::erase(const_iterator first, const_iterator last) { +dynamic::iterator dynamic::erase(const_iterator first, const_iterator last) { auto& arr = get(); return get().erase( arr.begin() + (first - arr.begin()), @@ -277,9 +278,8 @@ std::size_t dynamic::hash() const { const auto& str = getString(); return ::folly::hash::fnv32_buf(str.data(), str.size()); } - default: - CHECK(0); abort(); } + assume_unreachable(); } char const* dynamic::typeName(Type t) {