diff --git a/API/fleece/Fleece.hh b/API/fleece/Fleece.hh index 37ef6d9b..7a6e75ad 100644 --- a/API/fleece/Fleece.hh +++ b/API/fleece/Fleece.hh @@ -39,7 +39,6 @@ namespace fleece { class Value { public: Value() =default; - Value(const Value &) noexcept =default; Value(FLValue FL_NULLABLE v) :_val(v) { } operator FLValue FL_NULLABLE () const {return _val;} @@ -116,7 +115,6 @@ namespace fleece { public: Array() :Value() { } Array(FLArray FL_NULLABLE a) :Value((FLValue)a) { } - Array(const Array&) noexcept = default; operator FLArray FL_NULLABLE () const {return (FLArray)_val;} static Array emptyArray() {return Array(kFLEmptyArray);} @@ -169,7 +167,6 @@ namespace fleece { public: Dict() :Value() { } Dict(FLDict FL_NULLABLE d) :Value((FLValue)d) { } - Dict(const Dict&) noexcept = default; operator FLDict FL_NULLABLE () const {return (FLDict)_val;} static Dict emptyDict() {return Dict(kFLEmptyDict);} diff --git a/API/fleece/slice.hh b/API/fleece/slice.hh index 4d83be41..db0b51ac 100644 --- a/API/fleece/slice.hh +++ b/API/fleece/slice.hh @@ -202,10 +202,11 @@ namespace fleece { # endif #endif + constexpr pure_slice(const pure_slice &s) noexcept = default; constexpr pure_slice(std::nullptr_t) noexcept :pure_slice() {} constexpr pure_slice(const char* FL_NULLABLE str) noexcept :buf(str), size(_strlen(str)) {} pure_slice(const std::string& str LIFETIMEBOUND) noexcept :buf(str.data()), size(str.size()) {} - constexpr pure_slice(std::string_view str) noexcept :pure_slice(str.data(), str.length()) {} + constexpr pure_slice(std::string_view str) noexcept :buf(str.data()), size(str.size()) {} // Raw memory allocation. These throw std::bad_alloc on failure. RETURNS_NONNULL inline static void* newBytes(size_t sz); @@ -568,7 +569,7 @@ namespace fleece { inline std::string pure_slice::hexString() const { - static const char kDigits[17] = "0123456789abcdef"; + static constexpr char kDigits[17] = "0123456789abcdef"; std::string result; result.reserve(2 * size); for (size_t i = 0; i < size; i++) { @@ -747,8 +748,7 @@ namespace fleece { inline void slice::setStart(const void *s) noexcept { - check(s); - set(s, pointerDiff(end(), s)); + set(check(s), pointerDiff(end(), s)); } @@ -848,10 +848,10 @@ namespace std { // Declare the default hash function for `slice` and `alloc_slice`. This allows them to be // used in hashed collections like `std::unordered_map` and `std::unordered_set`. template<> struct hash { - std::size_t operator() (fleece::pure_slice const& s) const {return s.hash();} + std::size_t operator() (fleece::pure_slice const& s) const noexcept {return s.hash();} }; template<> struct hash { - std::size_t operator() (fleece::pure_slice const& s) const {return s.hash();} + std::size_t operator() (fleece::pure_slice const& s) const noexcept {return s.hash();} }; } diff --git a/Fleece/API_Impl/FLEncoder.cc b/Fleece/API_Impl/FLEncoder.cc index 92f0ce5e..46f9bb23 100644 --- a/Fleece/API_Impl/FLEncoder.cc +++ b/Fleece/API_Impl/FLEncoder.cc @@ -13,9 +13,12 @@ #include "Fleece+ImplGlue.hh" #include "Builder.hh" -#define ENCODER_DO(E, METHOD) (E)->do_([&](auto& e) {return e.METHOD;}) +using namespace fleece; +using namespace fleece::impl; -#define ENCODER_TRY(E, METHOD) return (E)->try_([&](auto e) { ENCODER_DO(e, METHOD); return true;}) +#define ENCODER_DO(E, METHOD) (E)->do_([&](auto& _e1) {return _e1.METHOD;}) + +#define ENCODER_TRY(E, METHOD) return (E)->try_([&](auto _e2) { ENCODER_DO(_e2, METHOD); return true;}) FLEncoder FLEncoder_New(void) FLAPI { return FLEncoder_NewWithOptions(kFLEncodeFleece, 0, true); diff --git a/Fleece/API_Impl/Fleece+ImplGlue.hh b/Fleece/API_Impl/Fleece+ImplGlue.hh index f0aa2eb1..992722ac 100644 --- a/Fleece/API_Impl/Fleece+ImplGlue.hh +++ b/Fleece/API_Impl/Fleece+ImplGlue.hh @@ -22,10 +22,6 @@ #include #include -using namespace fleece; -using namespace fleece::impl; - - namespace fleece::impl { class FLEncoderImpl; } diff --git a/Fleece/Core/Builder.cc b/Fleece/Core/Builder.cc index 12ca47dc..816fc733 100644 --- a/Fleece/Core/Builder.cc +++ b/Fleece/Core/Builder.cc @@ -79,7 +79,7 @@ namespace fleece::impl::builder { protected: // Parses a Fleece value from the input and stores it in the ValueSlot. // Recognizes a '%' specifier, and calls `putParameter` to read the value from the args. - const bool _buildValue(ValueSlot &inSlot) { + bool _buildValue(ValueSlot &inSlot) { switch (peekValue()) { case ValueType::array: { Retained array = MutableArray::newArray(); @@ -207,7 +207,7 @@ namespace fleece::impl::builder { protected: // Parses a Fleece value from the input and writes it, prefixed by the key if one's given. // Recognizes a '%' specifier, and calls `writeParameter` to read the value from the args. - const bool writeValue(slice key = nullslice) { + bool writeValue(slice key = nullslice) { auto v = peekValue(); if (v != ValueType::arg && key) _encoder.writeKey(key); diff --git a/Fleece/Support/JSONEncoder.hh b/Fleece/Support/JSONEncoder.hh index 65e5d7b6..28e6c0ff 100644 --- a/Fleece/Support/JSONEncoder.hh +++ b/Fleece/Support/JSONEncoder.hh @@ -66,11 +66,11 @@ namespace fleece { namespace impl { void writeRaw(slice raw) {_out << raw;} #ifdef __APPLE__ - void writeCF(const void*) {FleeceException::_throw(JSONError, + [[noreturn]] void writeCF(const void*) {FleeceException::_throw(JSONError, "Encoding CF value to JSON is unimplemented");} #endif #ifdef __OBJC__ - void writeObjC(id) {FleeceException::_throw(JSONError, + [[noreturn]] void writeObjC(id) {FleeceException::_throw(JSONError, "Encoding Obj-C to JSON is unimplemented");} #endif