From 83778c50054e54bda9cee8a5f1c540701fb45395 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 14 Nov 2019 10:18:45 -0800 Subject: [PATCH] doc work --- CMakeLists.txt | 2 +- doc/qbk/main.qbk | 4 +- doc/qbk/quickref.qbk | 117 -- doc/qbk/quickref.xml | 90 ++ doc/source.dox | 2 +- include/boost/json.hpp | 2 +- include/boost/json/array.hpp | 421 ++--- include/boost/json/assign_string.hpp | 4 +- include/boost/json/assign_vector.hpp | 4 +- include/boost/json/basic_parser.hpp | 4 +- include/boost/json/block_storage.hpp | 4 +- include/boost/json/config.hpp | 48 + include/boost/json/detail/array_impl.hpp | 4 +- include/boost/json/detail/buffer.hpp | 4 +- include/boost/json/detail/config.hpp | 6 +- include/boost/json/detail/except.hpp | 2 +- include/boost/json/detail/format.hpp | 2 +- include/boost/json/detail/format.ipp | 2 +- include/boost/json/detail/impl/array_impl.hpp | 2 +- include/boost/json/detail/impl/array_impl.ipp | 2 +- .../boost/json/detail/impl/object_impl.hpp | 13 +- .../boost/json/detail/impl/object_impl.ipp | 24 +- .../boost/json/detail/impl/string_impl.ipp | 2 +- include/boost/json/detail/number.hpp | 4 +- include/boost/json/detail/number.ipp | 2 +- include/boost/json/detail/object_impl.hpp | 22 +- include/boost/json/detail/raw_stack.hpp | 4 +- include/boost/json/detail/raw_stack.ipp | 2 +- .../boost/json/detail/ryu/detail/common.hpp | 2 +- include/boost/json/detail/ryu/detail/d2s.hpp | 2 +- .../json/detail/ryu/detail/d2s_full_table.hpp | 2 +- .../json/detail/ryu/detail/d2s_intrinsics.hpp | 2 +- .../json/detail/ryu/detail/digit_table.hpp | 2 +- include/boost/json/detail/ryu/ryu.hpp | 2 +- include/boost/json/detail/scalar_impl.hpp | 8 +- include/boost/json/detail/sse2.hpp | 4 +- include/boost/json/detail/static_stack.hpp | 4 +- include/boost/json/detail/string_impl.hpp | 4 +- include/boost/json/detail/value.hpp | 2 +- include/boost/json/error.hpp | 4 +- include/boost/json/impl/array.hpp | 2 +- include/boost/json/impl/array.ipp | 2 +- include/boost/json/impl/basic_parser.ipp | 2 +- include/boost/json/impl/error.hpp | 2 +- include/boost/json/impl/error.ipp | 2 +- include/boost/json/impl/object.hpp | 11 +- include/boost/json/impl/object.ipp | 4 +- include/boost/json/impl/parser.ipp | 2 +- include/boost/json/impl/serializer.ipp | 4 +- include/boost/json/impl/storage_ptr.hpp | 2 +- include/boost/json/impl/string.hpp | 2 +- include/boost/json/impl/string.ipp | 2 +- include/boost/json/impl/value.hpp | 13 +- include/boost/json/impl/value.ipp | 43 +- include/boost/json/json.natvis | 4 +- include/boost/json/kind.hpp | 14 +- include/boost/json/object.hpp | 284 ++-- include/boost/json/parser.hpp | 4 +- include/boost/json/serializer.hpp | 4 +- include/boost/json/src.hpp | 4 +- include/boost/json/storage.hpp | 36 +- include/boost/json/storage_ptr.hpp | 50 +- include/boost/json/string.hpp | 360 +++-- include/boost/json/value.hpp | 1397 +++++++++++++---- include/boost/pilfer.hpp | 2 +- src/src.cpp | 2 +- test/CMakeLists.txt | 2 +- test/Jamfile | 2 +- test/array.cpp | 2 +- test/assign_string.cpp | 9 +- test/assign_vector.cpp | 19 +- test/basic_parser.cpp | 2 +- test/block_storage.cpp | 2 +- test/error.cpp | 2 +- test/json.cpp | 2 +- test/kind.cpp | 2 +- test/limits.cpp | 2 +- test/main.cpp | 2 +- test/number.cpp | 2 +- test/object.cpp | 2 +- test/parse-vectors.hpp | 2 +- test/parser.cpp | 2 +- test/ryu/gtest.hpp | 2 +- test/serializer.cpp | 2 +- test/storage.cpp | 2 +- test/storage_ptr.cpp | 2 +- test/string.cpp | 28 +- test/test.hpp | 8 +- test/value.cpp | 286 +++- 89 files changed, 2363 insertions(+), 1114 deletions(-) delete mode 100644 doc/qbk/quickref.qbk create mode 100644 doc/qbk/quickref.xml create mode 100644 include/boost/json/config.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bb97528..12d45c88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/qbk/main.qbk b/doc/qbk/main.qbk index c289946f..4d813c46 100644 --- a/doc/qbk/main.qbk +++ b/doc/qbk/main.qbk @@ -110,8 +110,10 @@ in memory. [include usage.qbk] [include comparison.qbk] [include benchmarks.qbk] -[include quickref.qbk] +[section:quickref Reference] +[xinclude quickref.xml] +[endsect] [section:ref Reference] [include reference.qbk] [endsect] diff --git a/doc/qbk/quickref.qbk b/doc/qbk/quickref.qbk deleted file mode 100644 index b9fa8f31..00000000 --- a/doc/qbk/quickref.qbk +++ /dev/null @@ -1,117 +0,0 @@ -[/ - Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com) - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - Official repository: https://github.com/vinniefalco/json -] - -[section:quickref Reference] - -[table -[[Identifier] [Description]] -[ - [[link json.ref.boost__json__array `array`]] - [ - The container used to represent JSON values of array type. - ] -][ - [[link json.ref.boost__json__basic_parser `basic_parser`]] - [ - An abstract base class which implements the JSON parser. - ] -][ - [[link json.ref.boost__json__condition `condition`]] - [ - Error condition values corresponding to JSON errors. - ] -][ - [[link json.ref.boost__json__error `error`]] - [ - Error code values returned by JSON operations. - ] -][ - [[link json.ref.boost__json__has_from_json `has_from_json`]] - [ - Trait to determine if a type can be assigned to a JSON - [link json.ref.boost__json__value `value`]. - ] -][ - [[link json.ref.boost__json__has_to_json `has_to_json`]] - [ - Trait to determine if a JSON - [link json.ref.boost__json__value `value`] - can be constructed or assigned from a type. - ] -][ - [[link json.ref.boost__json__ieee_decimal `ieee_decimal`]] - [ - Describes an IEEE floating point value using - an unsigned integer and base-10 exponent. - ] -][ - [[link json.ref.boost__json__kind `kind`]] - [ - An enumeration which describes the JSON value's type. - ] -][ - [[link json.ref.boost__json__object `object`]] - [ - The container used to represent JSON values of object type. - ] -][ - [[link json.ref.boost__json__parser `parser`]] - [ - A JSON parser which stores the resulting document in a - [link json.ref.boost__json__value `value`] - object. - ] -][ - [[link json.ref.boost__json__serializer `serializer`]] - [ - An object used to convert a - [link json.ref.boost__json__value `value`] - into its serialized representation. - ] -][ - [ - [link json.ref.boost__json__scoped_storage `scoped_storage`] - ][ - A smart container for type-erased - [link json.ref.boost__json__storage `storage`] - object whose allocations have a scoped lifetime. - ] -][ - [[link json.ref.boost__json__storage `storage`]] - [ - Abstract interface to a memory resource used with JSON. - ] -][ - [ - [link json.ref.boost__json__storage_ptr `storage_ptr`] - ][ - Smart pointer container for a reference counted, type-erased - [link json.ref.boost__json__storage `storage`] - object. - ] -][ - [[link json.ref.boost__json__string `string`]] - [ - The container used to represent JSON values of string type. - ] -][ - [[link json.ref.boost__json__value `value`]] - [ - The type used to represent any JSON value. - ] -][ - [[link json.ref.boost__json__value_exchange `value_exchange`]] - [ - Class template customization point for converting between - user defined types and JSON - [link json.ref.boost__json__value `value`] types. - ] -]] - -[endsect] diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml new file mode 100644 index 00000000..3f76abdf --- /dev/null +++ b/doc/qbk/quickref.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + JSON + + + + Classes + + array + basic_parser + block_storage + key_value_pair + object + parser + scoped_storage + serializer + storage + storage_ptr + string + value + + + + Functions + + make_storage + parse + swap + to_string + + Type Traits + + has_from_json + has_to_json + value_exchange + + + + Operators + + operator== + operator!= + operator< + operator<= + operator>= + operator> + operator<< + + + + Constants + + array_kind + condition + error + kind + object_kind + string_kind + + + + Aliases + + error_category + error_code + error_condition + string_view + system_error + + + + + diff --git a/doc/source.dox b/doc/source.dox index 0f3f651a..b52aa856 100644 --- a/doc/source.dox +++ b/doc/source.dox @@ -55,7 +55,7 @@ PREDEFINED = \ BOOST_JSON_DECL \ BOOST_JSON_PUBLIC \ BOOST_JSON_FORCEINLINE \ - "BOOST_JSON_INLINE_VARIABLE(v, t)= " + "BOOST_JSON_INLINE_VARIABLE(v, t)=constexpr t v;" EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES diff --git a/include/boost/json.hpp b/include/boost/json.hpp index 529e915b..e16b02d3 100644 --- a/include/boost/json.hpp +++ b/include/boost/json.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/array.hpp b/include/boost/json/array.hpp index 488d9882..9b9c0644 100644 --- a/include/boost/json/array.hpp +++ b/include/boost/json/array.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_ARRAY_HPP #define BOOST_JSON_ARRAY_HPP -#include +#include #include #include #include @@ -26,44 +26,57 @@ class value; /** A dynamically sized array of JSON values - This is the type used to represent JSON values of kind array. - It is modeled for equivalence to `std::vector`. + This is the type used to represent JSON array values. It + is modeled for equivalence to `std::vector`. - The elements are stored contiguously, which means that elements - can be accessed not only through iterators, but also using offsets - to regular pointers to elements. This means that a pointer to an - element of an @ref array may be passed to any function that expects - a pointer to @ref value. +
- The storage of the array is handled automatically, being expanded - and contracted as needed. Arrays usually occupy more space than - array language constructs, because more memory is allocated to - handle future growth. This way an array does not need to reallocate - each time an element is inserted, but only when the additional - memory is exhausted. The total amount of allocated memory can be - queried using the @ref capacity function. Extra memory can be + The elements are stored contiguously, which means that + elements can be accessed not only through iterators, but + also using offsets to regular pointers to elements. A + pointer to an element of an @ref array may be passed to + any function that expects a pointer to @ref value. + +
+ + The storage of the array is handled automatically, being + expanded and contracted as needed. Arrays usually occupy + more space than array language constructs, because more + memory is allocated to handle future growth. This way an + array does not need to reallocate each time an element + is inserted, but only when the additional memory is used + up. The total amount of allocated memory can be queried + using the @ref capacity function. Extra memory can be relinquished by calling @ref shrink_to_fit. - Reallocations are usually costly operations in terms of performance. - The @ref reserve function can be used to eliminate reallocations - if the number of elements is known beforehand. +
- The complexity (efficiency) of common operations on arrays is as follows: + Reallocations are usually costly operations in terms of + performance. The @ref reserve function can be used to + eliminate reallocations if the number of elements is + known beforehand. - @li Random access - constant *O(1)* - @li Insertion or removal of elements at the end - amortized constant *O(1)* - @li Insertion or removal of elements - linear in the distance to the end of - the array *O(n)* +
+ + The complexity (efficiency) of common operations on + arrays is as follows: + + @li Random access - constant *O(1)*. + @li Insertion or removal of elements at the + end - amortized constant *O(1)*. + @li Insertion or removal of elements - linear in + the distance to the end of the array *O(n)*. @par Storage - All elements stored in the container will use the same storage that - was used to construct the container, including recursive children - of those elements. + All elements stored in the container, and their + children if any, will use the same storage that + was used to construct the container. @par Thread Safety - Non-const member functions may not be called concurrently. + Non-const member functions may not be called + concurrently with any other member functions. @par Satisfies @@ -123,15 +136,15 @@ public: //------------------------------------------------------ - /** Destroy the container + /** Destructor. - The destructor for each element is called, any used - memory is deallocated, and shared ownership of the - underlying storage is released. + The destructor for each element is called if needed, + any used memory is deallocated, and shared ownership + of the @ref storage is released. @par Complexity - Linear in @ref size() + Constant, or linear in @ref size(). */ ~array() { @@ -149,10 +162,10 @@ public: //------------------------------------------------------ - /** Construct an empty container + /** Default constructor. - The container and all inserted elements will use the - @ref storage returned by default storage. + The constructed array is empty with zero + capacity, using the default storage. @par Complexity @@ -164,10 +177,10 @@ public: */ array() = default; - /** Construct an empty container + /** Constructor. - The container and all inserted elements will use the - @ref storage owned by `sp`. + The constructed array is empty with zero + capacity, using the specified storage. @par Complexity @@ -185,12 +198,11 @@ public: explicit array(storage_ptr sp) noexcept; - /** Construct a container with `count` copies of `v` + /** Constructor. - The container and all inserted elements will use the - @ref storage owned by `sp`, - or the default parameter value returned by - default storage if this argument is omitted. + The array is constructed with `count` + copies of the value `v`, using the + specified storage will be used. @par Complexity @@ -215,12 +227,10 @@ public: value const& v, storage_ptr sp = {}); - /** Construct a container with `count` null values + /** Constructor. - The container and all inserted elements will use the - @ref storage owned by `sp`, - or the default parameter value returned by - default storage if this argument is omitted. + The array is constructed with `count` null values, + using the specified storage. @par Complexity @@ -231,7 +241,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param count The number of copies to insert. + @param count The number of nulls to insert. @param sp A pointer to the @ref storage to use. The container will acquire shared @@ -242,14 +252,11 @@ public: std::size_t count, storage_ptr sp = {}); - /** Construct a container with the contents of a range + /** Constructor. - The elements in the range `[first, last)` are - inserted in order. - The container and all inserted elements will use the - @ref storage owned by `sp`, - or the default parameter value returned by - default storage if this argument is omitted. + The array is constructed with the elements + in the range `[first, last)`, preserving order, + using the specified storage. @par Constraints @@ -266,8 +273,9 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param first An input iterator pointing to the first - element to insert, or pointing to the end of the range. + @param first An input iterator pointing to the + first element to insert, or pointing to the end + of the range. @param last An input iterator pointing to the end of the range. @@ -292,12 +300,10 @@ public: InputIt first, InputIt last, storage_ptr sp = {}); - /** Copy constructor + /** Copy constructor. - Constructs the container with a copy of the contents - of `other`. - The container and all inserted elements will use the - @ref storage returned by default storage. + The array is constructed with a copy of the + contents of `other`, using the storage of `other`. @par Complexity @@ -308,17 +314,15 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to copy + @param other The array to copy */ BOOST_JSON_DECL array(array const& other); - /** Copy constructor + /** Copy constructor. - Constructs the container with a copy of the contents - of `other`. - The container and all inserted elements will use the - @ref storage owned by `sp`. + The array is constructed with a copy of the + contents of `other`, using the specified storage. @par Complexity @@ -329,7 +333,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to copy + @param other The array to copy @param sp A pointer to the @ref storage to use. The container will acquire shared @@ -340,16 +344,15 @@ public: array const& other, storage_ptr sp); - /** Pilfer constructor + /** Pilfer constructor. - Constructs the container with the contents of `other` - using pilfer semantics. - Ownership of the @ref storage is transferred. + The array is constructed by acquiring ownership of + the contents of `other` using pilfer semantics. @note - After construction, the moved-from object may only be - destroyed. + After construction, the moved-from array may only + be destroyed. @par Complexity @@ -359,7 +362,7 @@ public: No-throw guarantee. - @param other The container to pilfer + @param other The array to pilfer @see @@ -369,18 +372,17 @@ public: BOOST_JSON_DECL array(pilfered other) noexcept; - /** Move constructor + /** Move constructor. - Constructs the container with the contents of `other` - using move semantics. Ownership of the underlying - memory is transferred. - The container acquires shared ownership of the - @ref storage used by `other`. + The array is constructed by acquiring ownership of + the contents of `other` and shared ownership of + the storage of `other`. @note - After construction, the moved-from object behaves as - if newly constructed with its current storage pointer. + After construction, the moved-from array behaves + as if newly constructed with its current storage + pointer. @par Complexity @@ -395,23 +397,23 @@ public: BOOST_JSON_DECL array(array&& other) noexcept; - /** Move constructor + /** Move constructor. - Using `*sp` as the @ref storage for the new container, - moves all the elements from `other`. + The array is constructed with the contents of + `other` by move semantics, using the specified + storage: - @li If `*other.get_storage() == *sp`, ownership of the - underlying memory is transferred in constant time, with - no possibility of exceptions. - After construction, the moved-from object behaves as if - newly constructed with its current @ref storage pointer. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. + After construction, the moved-from array behaves + as if newly constructed with its current storage + pointer. - @li If `*other.get_storage() != *sp`, an element-wise - copy is performed. In this case, the moved-from container - is not changed. - - The container and all inserted elements will use the - specified storage. + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed, which may throw. + In this case, the moved-from array is not + changed. @par Complexity @@ -424,20 +426,20 @@ public: @param other The container to move - @param sp A pointer to the @ref storage to use. The - container will acquire shared ownership of the pointer. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL array( array&& other, storage_ptr sp); - /** Constructs the container with the contents of an initializer list + /** Constructor. - The container and all inserted elements will use the - @ref storage owned by `sp`, - or the default parameter value returned by - default storage if this argument is omitted. + The array is constructed with a copy of the values + in the initializer-list in order, using the + specified storage. @par Complexity @@ -461,9 +463,10 @@ public: //------------------------------------------------------ - /** Copy assignment operator + /** Copy assignment. - Replaces the contents with an element-wise copy of other. + The contents of the array are replaced with an + element-wise copy of `other`. @par Complexity @@ -474,46 +477,49 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to copy + @param other The array to copy. */ BOOST_JSON_DECL array& operator=(array const& other); - /** Move assignment operator + /** Move assignment. - Replaces the contents with those of `other` using move - semantics (the data in `other` is moved into this container). + The contents of the array are replaced with the + contents of `other` using move semantics: - @li If `*other.get_storage() == get_storage()`, - ownership of the underlying memory is transferred in - constant time, with no possibility of exceptions. - After construction, the moved-from object behaves as if - newly constructed with its current @ref storage pointer. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. + After assignment, the moved-from array behaves + as if newly constructed with its current storage + pointer. - @li If `*other.get_storage() != *sp`, an element-wise - copy is performed. In this case the moved-from container - is not modified, and exceptions may be thrown. + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed, which may throw. + In this case, the moved-from array is not + changed. @par Complexity - At most, linear in `this->size()` plus `other.size()`. + Constant, or linear in + `this->size()` plus `other.size()`. @par Exception Safety Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to assign from + @param other The array to move. */ BOOST_JSON_DECL array& operator=(array&& other); - /** Assign the contents of an initializer list + /** Assignment. - Replaces the contents with the contents of an - initializer list. + The contents of the array are replaced with a + copy of the values in the initializer-list. @par Complexity @@ -524,7 +530,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param init The initializer list to assign + @param init The initializer list to copy. */ BOOST_JSON_DECL array& @@ -533,10 +539,10 @@ public: //------------------------------------------------------ - /** Return a pointer to the storage associated with the container + /** Return the storage used by the array. - Shared ownership of the @ref storage is propagated by - the container to all of its children recursively. + This returns the storage used by the array + for all elements and all internal allocations. @par Complexity @@ -554,18 +560,18 @@ public: // //------------------------------------------------------ - /** Access an element, with bounds checking + /** Access an element, with bounds checking. Returns a reference to the element specified at - location `pos`, with bounds checking. If pos is not - within the range of the container, an exception of - type `std::out_of_range` is thrown. + location `pos`, with bounds checking. If `pos` is + not within the range of the container, an exception + of type `std::out_of_range` is thrown. @par Complexity Constant. - @param pos A zero-based index + @param pos A zero-based index. @throws std::out_of_range `pos >= size()` */ @@ -573,18 +579,18 @@ public: reference at(std::size_t pos); - /** Access an element, with bounds checking + /** Access an element, with bounds checking. Returns a reference to the element specified at - location `pos`, with bounds checking. If pos is not - within the range of the container, an exception of - type `std::out_of_range` is thrown. + location `pos`, with bounds checking. If `pos` is + not within the range of the container, an exception + of type `std::out_of_range` is thrown. @par Complexity Constant. - @param pos A zero-based index + @param pos A zero-based index. @throws std::out_of_range `pos >= size()` */ @@ -592,14 +598,14 @@ public: const_reference at(std::size_t pos) const; - /** Access an element + /** Access an element. Returns a reference to the element specified at location `pos`. No bounds checking is performed. @par Precondition - `pos >= size` + `pos < size()` @par Complexity @@ -611,14 +617,14 @@ public: reference operator[](std::size_t pos) noexcept; - /** Access an element + /** Access an element. Returns a reference to the element specified at location `pos`. No bounds checking is performed. @par Precondition - `pos >= size` + `pos < size()` @par Complexity @@ -630,7 +636,7 @@ public: const_reference operator[](std::size_t pos) const noexcept; - /** Access the first element + /** Access the first element. Returns a reference to the first element. @@ -646,7 +652,7 @@ public: reference front() noexcept; - /** Access the first element + /** Access the first element. Returns a reference to the first element. @@ -662,7 +668,7 @@ public: const_reference front() const noexcept; - /** Access the last element + /** Access the last element. Returns a reference to the last element. @@ -678,7 +684,7 @@ public: reference back() noexcept; - /** Access the last element + /** Access the last element. Returns a reference to the last element. @@ -694,11 +700,11 @@ public: const_reference back() const noexcept; - /** Access the underlying array directly + /** Access the underlying array directly. Returns a pointer to the underlying array serving as element storage. The value returned is such that - the range `[data(), data()+size())` is always a + the range `[data(), data() + size())` is always a valid range, even if the container is empty. @par Complexity @@ -714,11 +720,11 @@ public: value* data() noexcept; - /** Access the underlying array directly + /** Access the underlying array directly. Returns a pointer to the underlying array serving as element storage. The value returned is such that - the range `[data(), data()+size())` is always a + the range `[data(), data() + size())` is always a valid range, even if the container is empty. @par Complexity @@ -740,7 +746,7 @@ public: // //------------------------------------------------------ - /** Return an iterator to the first element + /** Return an iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -753,7 +759,7 @@ public: iterator begin() noexcept; - /** Return an iterator to the first element + /** Return a const iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -766,7 +772,7 @@ public: const_iterator begin() const noexcept; - /** Return an iterator to the first element + /** Return a const iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -779,7 +785,7 @@ public: const_iterator cbegin() const noexcept; - /** Return an iterator to the element following the last element + /** Return an iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -792,7 +798,7 @@ public: iterator end() noexcept; - /** Return an iterator to the element following the last element + /** Return a const iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -805,7 +811,7 @@ public: const_iterator end() const noexcept; - /** Return an iterator to the element following the last element + /** Return a const iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -818,7 +824,7 @@ public: const_iterator cend() const noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -832,7 +838,7 @@ public: reverse_iterator rbegin() noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a const reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -846,7 +852,7 @@ public: const_reverse_iterator rbegin() const noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a const reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -860,7 +866,7 @@ public: const_reverse_iterator crbegin() const noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -875,7 +881,7 @@ public: reverse_iterator rend() noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a const reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -890,7 +896,7 @@ public: const_reverse_iterator rend() const noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a const reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -911,10 +917,10 @@ public: // //------------------------------------------------------ - /** Check if the container has no elements + /** Check if the array has no elements. - Returns `true` if there are no elements in the container, - i.e. @ref size() returns 0. + Returns `true` if there are no elements in the + array, i.e. @ref size() returns 0. @par Complexity @@ -926,10 +932,10 @@ public: return impl_.size() == 0; } - /** Return the number of elements in the container + /** Return the number of elements in the array. - This returns the number of elements in the container. - The value returned may be different from the value + This returns the number of elements in the array. + The value returned may be different from the number returned from @ref capacity. @par Complexity @@ -942,12 +948,12 @@ public: return impl_.size(); } - /** Return the maximum number of elements the container can hold + /** Return the maximum number of elements the array can hold. - The maximum is an implementation-defined number dependent - on system or library implementation. This value is a - theoretical limit; at runtime, the actual maximum size - may be less due to resource limits. + The maximum is an implementation-defined number. + This value is a theoretical limit; at runtime, + the actual maximum size may be less due to + resource limits. @par Complexity @@ -961,7 +967,7 @@ public: return BOOST_JSON_MAX_ARRAY_SIZE; } - /** Return the number of elements that can be held in currently allocated memory + /** Return the number of elements that can be held in currently allocated memory. This number may be larger than the value returned by @ref size(). @@ -1016,13 +1022,15 @@ public: reserve_impl(new_capacity); } - /** Request the removal of unused capacity + /** Request the removal of unused capacity. - This performs a non-binding request to reduce @ref capacity() - to @ref size(). The request may or may not be fulfilled. If - reallocation occurs, all iterators including any past-the-end - iterators, and all references to the elements are invalidated. - Otherwise, no iterators or references are invalidated. + This performs a non-binding request to reduce the + capacity to the current size. The request may or + may not be fulfilled. If reallocation occurs, all + iterators including any past-the-end iterators, + and all references to the elements are invalidated. + Otherwise, no iterators or references are + invalidated. @par Complexity @@ -1042,7 +1050,7 @@ public: // //------------------------------------------------------ - /** Clear the contents + /** Clear the contents. Erases all elements from the container. After this call, @ref size() returns zero but @ref capacity() @@ -1058,7 +1066,7 @@ public: void clear() noexcept; - /** Insert elements before the specified location + /** Insert elements before the specified location. This inserts a copy of `v` before `pos`. If `capacity() < size() + 1`, a reallocation @@ -1093,7 +1101,7 @@ public: return emplace(pos, v); } - /** Insert elements before the specified location + /** Insert elements before the specified location. This inserts `v` before `pos` via move-construction. If `capacity() < size() + 1`, a reallocation occurs @@ -1129,7 +1137,7 @@ public: return emplace(pos, std::move(v)); } - /** Insert elements before the specified location + /** Insert elements before the specified location. This inserts `count` copies of `v` before `pos`. If `capacity() < size() + count`, a reallocation @@ -1166,7 +1174,7 @@ public: std::size_t count, value const& v); - /** Insert elements before the specified location + /** Insert elements before the specified location. The elements in the range `[first, last)` are inserted in order. @@ -1231,7 +1239,7 @@ public: const_iterator pos, InputIt first, InputIt last); - /** Insert elements before the specified location + /** Insert elements before the specified location. The elements in the initializer list `init` are inserted in order. @@ -1265,7 +1273,7 @@ public: const_iterator pos, std::initializer_list init); - /** Insert a constructed element in-place + /** Insert a constructed element in-place. Inserts a new element into the container directly before `pos`. The element is constructed using placement-new @@ -1300,7 +1308,7 @@ public: const_iterator pos, Arg&& arg); - /** Erases elements from the container + /** Erase elements from the container. The element at `pos` is removed. @@ -1322,7 +1330,7 @@ public: iterator erase(const_iterator pos) noexcept; - /** Erases elements from the container + /** Erase elements from the container. The elements in the range `[first, last)` are removed. @@ -1406,7 +1414,7 @@ public: emplace_back(std::move(v)); } - /** Append a constructed element in-place + /** Append a constructed element in-place. Appends a new element to the end of the container's list of elements. @@ -1453,7 +1461,7 @@ public: void pop_back() noexcept; - /** Change the number of elements stored + /** Change the number of elements stored. Resizes the container to contain `count` elements. If `capacity() < size() + count`, a reallocation @@ -1483,7 +1491,7 @@ public: void resize(std::size_t count); - /** Change the number of elements stored + /** Change the number of elements stored. Resizes the container to contain `count` elements. If `capacity() < size() + count`, a reallocation @@ -1517,10 +1525,10 @@ public: std::size_t count, value const& v); - /** Swap the contents + /** Swap the contents. - Exchanges the contents of this container with another - container. Ownership of the respective @ref storage + Exchanges the contents of this array with another + array. Ownership of the respective @ref storage objects is not transferred. @li If `*other.get_storage() == *sp`, ownership of the @@ -1532,6 +1540,10 @@ public: logically swapped by making copies, which can throw. In this case all iterators and references are invalidated. + @par Preconditions + + `&other != this` + @par Complexity Constant or linear in @ref size() plus `other.size()`. @@ -1541,7 +1553,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to swap with + @param other The array to swap with. */ BOOST_JSON_DECL void @@ -1609,6 +1621,19 @@ private: std::size_t n) noexcept; }; +/** Exchange the given values. + + @par Preconditions + + `&lhs != &rhs` +*/ +inline +void +swap(array& lhs, array& rhs) +{ + lhs.swap(rhs); +} + } // json } // boost diff --git a/include/boost/json/assign_string.hpp b/include/boost/json/assign_string.hpp index 95074b61..6da9413f 100644 --- a/include/boost/json/assign_string.hpp +++ b/include/boost/json/assign_string.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_ASSIGN_STRING_HPP #define BOOST_JSON_ASSIGN_STRING_HPP -#include +#include #include #include #include diff --git a/include/boost/json/assign_vector.hpp b/include/boost/json/assign_vector.hpp index a47b722a..ee0521e8 100644 --- a/include/boost/json/assign_vector.hpp +++ b/include/boost/json/assign_vector.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_ASSIGN_VECTOR_HPP #define BOOST_JSON_ASSIGN_VECTOR_HPP -#include +#include #include #include #include diff --git a/include/boost/json/basic_parser.hpp b/include/boost/json/basic_parser.hpp index 8ba6c8fb..76a58b46 100644 --- a/include/boost/json/basic_parser.hpp +++ b/include/boost/json/basic_parser.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_BASIC_PARSER_HPP #define BOOST_JSON_BASIC_PARSER_HPP -#include +#include #include #include #include diff --git a/include/boost/json/block_storage.hpp b/include/boost/json/block_storage.hpp index 4ce7b988..df7e165d 100644 --- a/include/boost/json/block_storage.hpp +++ b/include/boost/json/block_storage.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_BLOCK_STORAGE_HPP #define BOOST_JSON_BLOCK_STORAGE_HPP -#include +#include #include #include #include diff --git a/include/boost/json/config.hpp b/include/boost/json/config.hpp new file mode 100644 index 00000000..109c2d7a --- /dev/null +++ b/include/boost/json/config.hpp @@ -0,0 +1,48 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/vinniefalco/json +// + +#ifndef BOOST_JSON_CONFIG_HPP +#define BOOST_JSON_CONFIG_HPP + +#include + +namespace boost { +namespace json { + +#ifndef BOOST_JSON_STANDALONE + +/// The type of string view used by the library +using string_view = boost::string_view; + +/// The type of error code used by the library +using error_code = boost::system::error_code; + +/// The type of system error thrown by the library +using system_error = boost::system::system_error; + +/// The type of error category used by the library +using error_category = boost::system::error_category; + +/// The type of error condition used by the library +using error_condition = boost::system::error_condition; + +#else + +using error_code = std::error_code; +using error_category = std::error_category; +using error_condition = std::error_condition; +using string_view = std::string_view; +using system_error = std::system_error; + +#endif + +} // json +} // boost + +#endif diff --git a/include/boost/json/detail/array_impl.hpp b/include/boost/json/detail/array_impl.hpp index 21ca8697..84513243 100644 --- a/include/boost/json/detail/array_impl.hpp +++ b/include/boost/json/detail/array_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_ARRAY_IMPL_HPP #define BOOST_JSON_DETAIL_ARRAY_IMPL_HPP -#include +#include #include #include diff --git a/include/boost/json/detail/buffer.hpp b/include/boost/json/detail/buffer.hpp index 5591c96f..76119ce6 100644 --- a/include/boost/json/detail/buffer.hpp +++ b/include/boost/json/detail/buffer.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_BUFFER_HPP #define BOOST_JSON_DETAIL_BUFFER_HPP -#include +#include #include namespace boost { diff --git a/include/boost/json/detail/config.hpp b/include/boost/json/detail/config.hpp index 6226eb93..7bfcd8b5 100644 --- a/include/boost/json/detail/config.hpp +++ b/include/boost/json/detail/config.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -235,11 +235,11 @@ using error_condition = boost::system::error_condition; #else -using string_view = std::string_view; using error_code = std::error_code; -using system_error = std::system_error; using error_category = std::error_category; using error_condition = std::error_condition; +using string_view = std::string_view; +using system_error = std::system_error; #endif diff --git a/include/boost/json/detail/except.hpp b/include/boost/json/detail/except.hpp index 592cb4ef..2feecd60 100644 --- a/include/boost/json/detail/except.hpp +++ b/include/boost/json/detail/except.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/format.hpp b/include/boost/json/detail/format.hpp index 607bf6cd..0e129260 100644 --- a/include/boost/json/detail/format.hpp +++ b/include/boost/json/detail/format.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/format.ipp b/include/boost/json/detail/format.ipp index b85e1b6f..53488f71 100644 --- a/include/boost/json/detail/format.ipp +++ b/include/boost/json/detail/format.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/impl/array_impl.hpp b/include/boost/json/detail/impl/array_impl.hpp index 31aa1be6..4ada5423 100644 --- a/include/boost/json/detail/impl/array_impl.hpp +++ b/include/boost/json/detail/impl/array_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/impl/array_impl.ipp b/include/boost/json/detail/impl/array_impl.ipp index def12e59..6f874595 100644 --- a/include/boost/json/detail/impl/array_impl.ipp +++ b/include/boost/json/detail/impl/array_impl.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/impl/object_impl.hpp b/include/boost/json/detail/impl/object_impl.hpp index 65bc95ec..551bb5e3 100644 --- a/include/boost/json/detail/impl/object_impl.hpp +++ b/include/boost/json/detail/impl/object_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -20,16 +20,16 @@ struct next_access { static inline - object_value_type*& - get(object_value_type& e) noexcept + key_value_pair*& + get(key_value_pair& e) noexcept { return e.next_; } static inline - object_value_type const* - get(object_value_type const& e) noexcept + key_value_pair const* + get(key_value_pair const& e) noexcept { return e.next_; } @@ -161,8 +161,7 @@ unchecked_object:: ~unchecked_object() { if(data_) - object::value_type::destroy( - data_, size_); + destroy(data_, size_); } void diff --git a/include/boost/json/detail/impl/object_impl.ipp b/include/boost/json/detail/impl/object_impl.ipp index 53a6efbe..2fd87daa 100644 --- a/include/boost/json/detail/impl/object_impl.ipp +++ b/include/boost/json/detail/impl/object_impl.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -20,8 +20,7 @@ do_destroy(storage_ptr const& sp) noexcept { if(tab_) { - value_type::destroy( - begin(), size()); + detail::destroy(begin(), size()); sp->deallocate(tab_, sizeof(table) + capacity() * sizeof(value_type) + @@ -58,8 +57,7 @@ clear() noexcept { if(! tab_) return; - value_type::destroy( - begin(), size()); + detail::destroy(begin(), size()); std::memset(bucket_begin(), 0, buckets() * sizeof(value_type*)); tab_->size = 0; @@ -126,6 +124,22 @@ swap(object_impl& rhs) noexcept rhs.tab_ = tmp; } +//---------------------------------------------------------- + +void +destroy( + key_value_pair* p, + std::size_t n) noexcept +{ + if(n == 0) + return; + if(! p->value().get_storage()->need_free()) + return; + p += n; + while(n--) + (*--p).~key_value_pair(); +} + } // detail } // json } // boost diff --git a/include/boost/json/detail/impl/string_impl.ipp b/include/boost/json/detail/impl/string_impl.ipp index 30e9e158..c7470e0d 100644 --- a/include/boost/json/detail/impl/string_impl.ipp +++ b/include/boost/json/detail/impl/string_impl.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/number.hpp b/include/boost/json/detail/number.hpp index 4a7a9003..57e7b1d3 100644 --- a/include/boost/json/detail/number.hpp +++ b/include/boost/json/detail/number.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_NUMBER_HPP #define BOOST_JSON_DETAIL_NUMBER_HPP -#include +#include #include #include #include diff --git a/include/boost/json/detail/number.ipp b/include/boost/json/detail/number.ipp index 2764e872..eeacc8db 100644 --- a/include/boost/json/detail/number.ipp +++ b/include/boost/json/detail/number.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/object_impl.hpp b/include/boost/json/detail/object_impl.hpp index 518f9507..d48333b5 100644 --- a/include/boost/json/detail/object_impl.hpp +++ b/include/boost/json/detail/object_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_OBJECT_IMPL_HPP #define BOOST_JSON_DETAIL_OBJECT_IMPL_HPP -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace boost { namespace json { -struct object_value_type; +struct key_value_pair; namespace detail { @@ -30,7 +30,7 @@ class object_impl public: using value_type = - object_value_type; + key_value_pair; object_impl() = default; @@ -179,7 +179,7 @@ struct next_access; class unchecked_object { - object_value_type* data_; + key_value_pair* data_; std::size_t size_; storage_ptr const& sp_; @@ -188,7 +188,7 @@ public: ~unchecked_object(); unchecked_object( - object_value_type* data, + key_value_pair* data, std::size_t size, storage_ptr const& sp) noexcept : data_(data) @@ -220,9 +220,17 @@ public: inline void - relocate(object_value_type* dest) noexcept; + relocate(key_value_pair* dest) noexcept; }; +//---------------------------------------------------------- + +BOOST_JSON_DECL +void +destroy( + key_value_pair* p, + std::size_t n) noexcept; + } // detail } // json } // boost diff --git a/include/boost/json/detail/raw_stack.hpp b/include/boost/json/detail/raw_stack.hpp index 721bd35a..ef0c4895 100644 --- a/include/boost/json/detail/raw_stack.hpp +++ b/include/boost/json/detail/raw_stack.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_RAW_STACK_HPP #define BOOST_JSON_DETAIL_RAW_STACK_HPP -#include +#include #include #include #include diff --git a/include/boost/json/detail/raw_stack.ipp b/include/boost/json/detail/raw_stack.ipp index c45bc368..5ceee8be 100644 --- a/include/boost/json/detail/raw_stack.ipp +++ b/include/boost/json/detail/raw_stack.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/detail/ryu/detail/common.hpp b/include/boost/json/detail/ryu/detail/common.hpp index ed30deb9..0fd99a83 100644 --- a/include/boost/json/detail/ryu/detail/common.hpp +++ b/include/boost/json/detail/ryu/detail/common.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_DETAIL_COMMON_HPP #define BOOST_JSON_DETAIL_RYU_DETAIL_COMMON_HPP -#include +#include #include #include diff --git a/include/boost/json/detail/ryu/detail/d2s.hpp b/include/boost/json/detail/ryu/detail/d2s.hpp index fd31ab1c..dfbdaf63 100644 --- a/include/boost/json/detail/ryu/detail/d2s.hpp +++ b/include/boost/json/detail/ryu/detail/d2s.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_DETAIL_D2S_HPP #define BOOST_JSON_DETAIL_RYU_DETAIL_D2S_HPP -#include +#include #include #include diff --git a/include/boost/json/detail/ryu/detail/d2s_full_table.hpp b/include/boost/json/detail/ryu/detail/d2s_full_table.hpp index 778eb727..8e00dcc3 100644 --- a/include/boost/json/detail/ryu/detail/d2s_full_table.hpp +++ b/include/boost/json/detail/ryu/detail/d2s_full_table.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_DETAIL_D2S_FULL_TABLE_HPP #define BOOST_JSON_DETAIL_RYU_DETAIL_D2S_FULL_TABLE_HPP -#include +#include #include namespace boost { diff --git a/include/boost/json/detail/ryu/detail/d2s_intrinsics.hpp b/include/boost/json/detail/ryu/detail/d2s_intrinsics.hpp index f2fed62f..52137b5e 100644 --- a/include/boost/json/detail/ryu/detail/d2s_intrinsics.hpp +++ b/include/boost/json/detail/ryu/detail/d2s_intrinsics.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_DETAIL_D2S_INTRINSICS_HPP #define BOOST_JSON_DETAIL_RYU_DETAIL_D2S_INTRINSICS_HPP -#include +#include // This sets BOOST_JSON_RYU_32_BIT_PLATFORM as a side effect if applicable. #include diff --git a/include/boost/json/detail/ryu/detail/digit_table.hpp b/include/boost/json/detail/ryu/detail/digit_table.hpp index 80572fb4..885cbf84 100644 --- a/include/boost/json/detail/ryu/detail/digit_table.hpp +++ b/include/boost/json/detail/ryu/detail/digit_table.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_DETAIL_DIGIT_TABLE_HPP #define BOOST_JSON_DETAIL_RYU_DETAIL_DIGIT_TABLE_HPP -#include +#include namespace boost { namespace json { diff --git a/include/boost/json/detail/ryu/ryu.hpp b/include/boost/json/detail/ryu/ryu.hpp index 5c2e9f39..9e51c839 100644 --- a/include/boost/json/detail/ryu/ryu.hpp +++ b/include/boost/json/detail/ryu/ryu.hpp @@ -22,7 +22,7 @@ #ifndef BOOST_JSON_DETAIL_RYU_HPP #define BOOST_JSON_DETAIL_RYU_HPP -#include +#include #include namespace boost { diff --git a/include/boost/json/detail/scalar_impl.hpp b/include/boost/json/detail/scalar_impl.hpp index 502c49bb..7fc56b7a 100644 --- a/include/boost/json/detail/scalar_impl.hpp +++ b/include/boost/json/detail/scalar_impl.hpp @@ -118,7 +118,7 @@ struct bool_k bool b; bool_k() noexcept - : k(kind::boolean) + : k(kind::bool_) , b(false) { } @@ -127,16 +127,16 @@ struct bool_k bool_k( storage_ptr sp_) noexcept : sp(move(sp_)) - , k(kind::boolean) + , k(kind::bool_) , b(false) { } bool_k( - double b_, + bool b_, storage_ptr sp_) noexcept : sp(move(sp_)) - , k(kind::boolean) + , k(kind::bool_) , b(b_) { } diff --git a/include/boost/json/detail/sse2.hpp b/include/boost/json/detail/sse2.hpp index 6d3a1a79..62ab0bed 100644 --- a/include/boost/json/detail/sse2.hpp +++ b/include/boost/json/detail/sse2.hpp @@ -1,6 +1,6 @@ // // Copyright (c) 2019 Peter Dimov (pdimov at gmail dot com), -// Vinnie Falco (vinnie dot falco at gmail dot com) +// Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,7 +11,7 @@ #ifndef BOOST_JSON_DETAIL_SSE2_HPP #define BOOST_JSON_DETAIL_SSE2_HPP -#include +#include #include #ifdef BOOST_JSON_USE_SSE2 # include diff --git a/include/boost/json/detail/static_stack.hpp b/include/boost/json/detail/static_stack.hpp index 534de411..eae5e9e5 100644 --- a/include/boost/json/detail/static_stack.hpp +++ b/include/boost/json/detail/static_stack.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_STATIC_STACK_HPP #define BOOST_JSON_DETAIL_STATIC_STACK_HPP -#include +#include #include #include #include diff --git a/include/boost/json/detail/string_impl.hpp b/include/boost/json/detail/string_impl.hpp index b9b11715..c377ce74 100644 --- a/include/boost/json/detail/string_impl.hpp +++ b/include/boost/json/detail/string_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_DETAIL_STRING_IMPL_HPP #define BOOST_JSON_DETAIL_STRING_IMPL_HPP -#include +#include #include #include #include diff --git a/include/boost/json/detail/value.hpp b/include/boost/json/detail/value.hpp index 4a857a38..6fcc8cbd 100644 --- a/include/boost/json/detail/value.hpp +++ b/include/boost/json/detail/value.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/error.hpp b/include/boost/json/error.hpp index a5c8f52f..00105ec7 100644 --- a/include/boost/json/error.hpp +++ b/include/boost/json/error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_ERROR_HPP #define BOOST_JSON_ERROR_HPP -#include +#include namespace boost { namespace json { diff --git a/include/boost/json/impl/array.hpp b/include/boost/json/impl/array.hpp index 6bec57d0..112fdd77 100644 --- a/include/boost/json/impl/array.hpp +++ b/include/boost/json/impl/array.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/array.ipp b/include/boost/json/impl/array.ipp index 9e2506a2..2180ef4c 100644 --- a/include/boost/json/impl/array.ipp +++ b/include/boost/json/impl/array.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/basic_parser.ipp b/include/boost/json/impl/basic_parser.ipp index a2b59202..671ec518 100644 --- a/include/boost/json/impl/basic_parser.ipp +++ b/include/boost/json/impl/basic_parser.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/error.hpp b/include/boost/json/impl/error.hpp index cb5bdffb..12c8eed5 100644 --- a/include/boost/json/impl/error.hpp +++ b/include/boost/json/impl/error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/error.ipp b/include/boost/json/impl/error.ipp index 2744f852..5b34aa0c 100644 --- a/include/boost/json/impl/error.ipp +++ b/include/boost/json/impl/error.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/object.hpp b/include/boost/json/impl/object.hpp index 4d187782..6303eee5 100644 --- a/include/boost/json/impl/object.hpp +++ b/include/boost/json/impl/object.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -333,15 +333,6 @@ emplace( return emplace_impl(key, f); } -//---------------------------------------------------------- - -inline -void -swap(object& lhs, object& rhs) -{ - lhs.swap(rhs); -} - //---------------------------------------------------------- // // (implementation) diff --git a/include/boost/json/impl/object.ipp b/include/boost/json/impl/object.ipp index e6a2a1b2..013e7348 100644 --- a/include/boost/json/impl/object.ipp +++ b/include/boost/json/impl/object.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -46,7 +46,7 @@ public: for(auto it = p0; it != p1; ++it) self_.impl_.remove( self_.impl_.bucket(it->key()), it); - value_type::destroy(p0, last - first); + detail::destroy(p0, last - first); } } diff --git a/include/boost/json/impl/parser.ipp b/include/boost/json/impl/parser.ipp index 42cd569a..2ea99c4b 100644 --- a/include/boost/json/impl/parser.ipp +++ b/include/boost/json/impl/parser.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/serializer.ipp b/include/boost/json/impl/serializer.ipp index a2f78c01..4bc54cda 100644 --- a/include/boost/json/impl/serializer.ipp +++ b/include/boost/json/impl/serializer.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -181,7 +181,7 @@ loop_init: stack_->st = state::lit; goto loop; - case kind::boolean: + case kind::bool_: if(*jv.if_bool()) { if(p1 - p >= 4) diff --git a/include/boost/json/impl/storage_ptr.hpp b/include/boost/json/impl/storage_ptr.hpp index 9e4140dd..0e108c17 100644 --- a/include/boost/json/impl/storage_ptr.hpp +++ b/include/boost/json/impl/storage_ptr.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/string.hpp b/include/boost/json/impl/string.hpp index 65d91b99..53f8f71c 100644 --- a/include/boost/json/impl/string.hpp +++ b/include/boost/json/impl/string.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/string.ipp b/include/boost/json/impl/string.ipp index e616566f..d0f557dc 100644 --- a/include/boost/json/impl/string.ipp +++ b/include/boost/json/impl/string.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/json/impl/value.hpp b/include/boost/json/impl/value.hpp index dc0940c9..da9a6ba3 100644 --- a/include/boost/json/impl/value.hpp +++ b/include/boost/json/impl/value.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -147,18 +147,11 @@ value(detail::unchecked_array&& ua) { } -inline -void -swap(value& lhs, value& rhs) -{ - lhs.swap(rhs); -} - //---------------------------------------------------------- template -object_value_type:: -object_value_type( +key_value_pair:: +key_value_pair( string_view key, Args&&... args) : value_(std::forward(args)...) diff --git a/include/boost/json/impl/value.ipp b/include/boost/json/impl/value.ipp index 6ba3a0ac..0e535b92 100644 --- a/include/boost/json/impl/value.ipp +++ b/include/boost/json/impl/value.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -109,7 +109,7 @@ value:: dub_.~double_k(); break; - case json::kind::boolean: + case json::kind::bool_: bln_.~bool_k(); break; @@ -169,7 +169,7 @@ value( detail::move(sp)); break; - case json::kind::boolean: + case json::kind::bool_: ::new(&bln_) bool_k( other.bln_.b, detail::move(sp)); @@ -230,7 +230,7 @@ value( other.dub_.d, detail::move(sp)); break; - case json::kind::boolean: + case json::kind::bool_: ::new(&bln_) bool_k( other.bln_.b, detail::move(sp)); break; @@ -459,7 +459,7 @@ destroy() noexcept case json::kind::int64: case json::kind::uint64: case json::kind::double_: - case json::kind::boolean: + case json::kind::bool_: case json::kind::null: break; } @@ -468,17 +468,17 @@ destroy() noexcept //---------------------------------------------------------- -object_value_type:: -~object_value_type() +key_value_pair:: +~key_value_pair() { auto const& sp = value_.get_storage(); if(sp->need_free()) sp->deallocate(key_, len_ + 1, 1); } -object_value_type:: -object_value_type( - object_value_type const& other) +key_value_pair:: +key_value_pair( + key_value_pair const& other) : value_(other.value_) , len_(other.len_) , key_( @@ -494,10 +494,10 @@ object_value_type( { } -object_value_type:: -object_value_type:: -object_value_type( - object_value_type const& other, +key_value_pair:: +key_value_pair:: +key_value_pair( + key_value_pair const& other, storage_ptr sp) : value_(other.value_, detail::move(sp)) , len_(other.len_) @@ -514,21 +514,6 @@ object_value_type( { } -void -object_value_type:: -destroy( - object_value_type* p, - std::size_t n) noexcept -{ - if(n == 0) - return; - if(! p->value().get_storage()->need_free()) - return; - p += n; - while(n--) - (*--p).~object_value_type(); -} - //---------------------------------------------------------- } // json diff --git a/include/boost/json/json.natvis b/include/boost/json/json.natvis index 635bea4d..207d867b 100644 --- a/include/boost/json/json.natvis +++ b/include/boost/json/json.natvis @@ -9,7 +9,7 @@ {dub_.d} {i64_.i} {u64_.u}u - {bln_.b} + {bln_.b} null obj_ @@ -62,7 +62,7 @@ {{ {key_,[len_]s}, {value_.dub_.d} }} {{ {key_,[len_]s}, {value_.i64_.i} }} {{ {key_,[len_]s}, {value_.u64_.u} }} - {{ {key_,[len_]s}, {value_.bln_.b} }} + {{ {key_,[len_]s}, {value_.bln_.b} }} {{ {key_,[len_]s}, null }} &this->value_ diff --git a/include/boost/json/kind.hpp b/include/boost/json/kind.hpp index 0c6412d9..a21428d8 100644 --- a/include/boost/json/kind.hpp +++ b/include/boost/json/kind.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_KIND_HPP #define BOOST_JSON_KIND_HPP -#include +#include namespace boost { namespace json { @@ -27,19 +27,19 @@ enum class kind : unsigned char /// A @ref string. string, - /// A signed 64-bit integer. + /// A `std::int64_t` int64, - /// An unsigned 64-bit integer. + /// A `std::uint64_t` uint64, - /// A double precision floating point. + /// A `double`. double_, /// A `bool`. - boolean, + bool_, - /// A null. + /// The null value. null }; diff --git a/include/boost/json/object.hpp b/include/boost/json/object.hpp index 92ea5481..7f96d439 100644 --- a/include/boost/json/object.hpp +++ b/include/boost/json/object.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_OBJECT_HPP #define BOOST_JSON_OBJECT_HPP -#include +#include #include #include #include @@ -26,20 +26,48 @@ namespace json { class value; -/** An associative container of key to JSON value pairs +/** A dynamically sized associative container of JSON key/value pairs. This is an associative container whose elements are key/value pairs with unique keys. +
+ + The elements are stored contiguously, which means that + elements can be accessed not only through iterators, but + also using offsets to regular pointers to elements. A + pointer to an element of an @ref object may be passed to + any function that expects a pointer to + @ref key_value_pair. + +
+ + The container also maintains an internal index to speed + up find operations, reducing the average complexity + for most lookups and insertions + +
+ + Reallocations are usually costly operations in terms of + performance, as elements are copied and the internal + index must be rebuilt. The @ref reserve function can + be used to eliminate reallocations if the number of + elements is known beforehand. + @par Storage - All elements stored in the container will use the same - storage that was used to construct the container, - including the children of those elements. + All elements stored in the container, and their + children if any, will use the same storage that + was used to construct the container. + + @par Thread Safety + + Non-const member functions may not be called + concurrently with any other member functions. @par Satisfies - @ref object models + Meets the requirements of Container, ReversibleContainer, SequenceContainer, and @@ -60,7 +88,7 @@ class object template using is_inputit = typename std::enable_if< - std::is_constructible::value_type >::value>::type; @@ -75,8 +103,8 @@ class object public: /** The type of keys. - The implementation imposes a 2GB upper limit - on the size of keys. + The function @ref string::max_size returns the + maximum allowed size of strings used as keys. */ using key_type = string_view; @@ -84,7 +112,7 @@ public: using mapped_type = value; /// The element type - using value_type = object_value_type; + using value_type = key_value_pair; /// The type used to represent unsigned integers using size_type = std::size_t; @@ -126,9 +154,9 @@ public: /** Destructor. - If `this->get_storage()->need_free() == true`, - the destructor for each element is called, and - any allocated memory is deallocated. + The destructor for each element is called if needed, + any used memory is deallocated, and shared ownership + of the @ref storage is released. @par Complexity @@ -140,8 +168,6 @@ public: impl_.destroy(sp_); } - //------------------------------------------------------ - #ifndef GENERATING_DOCUMENTATION // private BOOST_JSON_DECL @@ -149,10 +175,12 @@ public: object(detail::unchecked_object&& uo); #endif + //------------------------------------------------------ + /** Default constructor. - The object starts out empty, with @ref capacity() - equal to zero. + The constructed object is empty with zero + capacity, using the default storage. @par Complexity @@ -164,10 +192,10 @@ public: */ object() = default; - /** Construct an object. + /** Constructor. - The object starts out empty, with @ref capacity() - equal to zero. + The constructed object is empty with zero + capacity, using the specified storage. @par Complexity @@ -177,17 +205,19 @@ public: No-throw guarantee. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL explicit - object( - storage_ptr sp) noexcept; + object(storage_ptr sp) noexcept; - /** Construct an object. + /** Constructor. - The object starts out empty, with @ref capacity() - greater than or equal to `min_capacity`. + The constructed object is empty with capacity + equal to the specified minimum capacity, + using the specified storage. @par Complexity @@ -202,17 +232,20 @@ public: of elements for which capacity is guaranteed without a subsequent reallocation. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL object( std::size_t min_capacity, storage_ptr sp = {}); - /** Construct an object. + /** Constructor. - The elements in the range `[first, last)` are - inserted, preserving their order. + The object is constructed with the elements + in the range `[first, last)`, preserving order, + using the specified storage. If multiple elements in the range have keys that compare equivalent, only the first occurring key will be inserted. @@ -234,8 +267,9 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param first An input iterator pointing to the first - element to insert, or pointing to the end of the range. + @param first An input iterator pointing to the + first element to insert, or pointing to the end + of the range. @param last An input iterator pointing to the end of the range. @@ -246,7 +280,9 @@ public: Upon construction, @ref capacity() will be greater than or equal to this number. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. @tparam InputIt a type meeting the requirements of __InputIterator__. @@ -265,11 +301,9 @@ public: /** Move constructor. - Construct the container with the contents of `other` - using move semantics. Ownership of the underlying - memory is transferred. - The container acquires shared ownership of the - @ref storage used by `other`. + The object is constructed by acquiring ownership of + the contents of `other` and shared ownership of + the storage of `other`. @note @@ -291,21 +325,21 @@ public: /** Move constructor. - Using `*sp` as the @ref storage for the new container, - moves all the elements from `other`. + The object is constructed with the contents of + `other` by move semantics, using the specified + storage: - @li If `*other.get_storage() == *sp`, ownership of the - underlying memory is transferred in constant time, with - no possibility of exceptions. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. After construction, the moved-from object behaves - as if newly constructed with its current storage. + as if newly constructed with its current storage + pointer. - @li If `*other.get_storage() != *sp`, an element-wise - copy is performed. In this case, the moved-from container - is not changed. - - The container and all inserted elements will use the - @ref storage owned by `sp`. + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed, which may throw. + In this case, the moved-from object is not + changed. @par Complexity @@ -318,7 +352,9 @@ public: @param other The object to move. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL object( @@ -327,14 +363,13 @@ public: /** Pilfer constructor. - Construct the container with the contents of `other` - using pilfer semantics. - Ownership of the @ref storage is transferred. + The object is constructed by acquiring ownership of + the contents of `other` using pilfer semantics. @note - After construction, the moved-from object may only be - destroyed. + After construction, the moved-from object may only + be destroyed. @par Complexity @@ -344,7 +379,7 @@ public: No-throw guarantee. - @param other The container to pilfer. + @param other The object to pilfer. @see @@ -356,10 +391,8 @@ public: /** Copy constructor. - Construct the container with a copy of the contents - of `other. - The container and all inserted elements will use the - default storage. + The object is constructed with a copy of the + contents of `other`, using the storage of `other`. @par Complexity @@ -378,10 +411,8 @@ public: /** Copy constructor. - Construct the container with a copy of the contents - of `other. - The container and all inserted elements will use the - specified storage. + The object is constructed with a copy of the + contents of `other`, using the specified storage. @par Complexity @@ -394,17 +425,20 @@ public: @param other The object to copy. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL object( object const& other, storage_ptr sp); - /** Construct an object. + /** Constructor. - The elements in the initializer list `init` are - inserted, preserving their order. + The object is constructed with a copy of the values + in the initializer-list in order, using the + specified storage. If multiple elements in the range have keys that compare equivalent, only the first occurring key will be inserted. @@ -420,7 +454,9 @@ public: @param init The initializer list to insert. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ object( init_list init, @@ -429,10 +465,13 @@ public: { } - /** Construct an object. + /** Constructor. - The elements in the initializer list `init` are - inserted, preserving their order. + Storage for at least `min_capacity` elements is + reserved, and then + the object is constructed with a copy of the values + in the initializer-list in order, using the + specified storage. If multiple elements in the range have keys that compare equivalent, only the first occurring key will be inserted. @@ -454,7 +493,9 @@ public: Upon construction, @ref capacity() will be greater than or equal to this number. - @param sp The @ref storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL object( @@ -462,21 +503,24 @@ public: std::size_t min_capacity, storage_ptr sp = {}); + //------------------------------------------------------ + /** Move assignment. - Replaces the contents with those of `other` - using move semantics (the data in `other` is - moved into this container). + The contents of the object are replaced with the + contents of `other` using move semantics: - @li If `*other.get_storage() == get_storage()`, - ownership of the underlying memory is transferred in - constant time, with no possibility of exceptions. - After construction, the moved-from object behaves as if - newly constructed with its current @ref storage pointer. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. + After assignment, the moved-from object behaves + as if newly constructed with its current storage + pointer. - @li If `*other.get_storage() != *sp`, an element-wise - copy is performed. In this case the moved-from container - is not modified, and exceptions may be thrown. + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed, which may throw. + In this case, the moved-from object is not + changed. @par Complexity @@ -487,7 +531,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The obect to assign from. + @param other The object to move. */ BOOST_JSON_DECL object& @@ -495,7 +539,8 @@ public: /** Copy assignment. - Replaces the contents with an element-wise copy of `other`. + The contents of the object are replaced with an + element-wise copy of `other`. @par Complexity @@ -506,36 +551,40 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The object to assign from. + @param other The object to copy. */ BOOST_JSON_DECL object& operator=(object const& other); - /** Assignment operator. + /** Assignment. Replaces the contents with the contents of an initializer list. @par Complexity - Linear in @ref size() plus `other.size()`. + Linear in @ref size() plus + average case linear in `init.size()`, + worst case quadratic in `init.size()`. @par Exception Safety Strong guarantee. Calls to @ref storage::allocate may throw. - @param init The initializer list to assign from. + @param init The initializer list to copy. */ BOOST_JSON_DECL object& operator=(init_list init); - /** Return the storage associated with the container. + //------------------------------------------------------ - Shared ownership of the @ref storage is propagated - by the container to all of its children recursively. + /** Return the storage used by the object. + + This returns the storage used by the object + for all elements and all internal allocations. @par Complexity @@ -553,7 +602,7 @@ public: // //------------------------------------------------------ - /** Return an iterator to the first element + /** Return an iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -566,7 +615,7 @@ public: iterator begin() noexcept; - /** Return an iterator to the first element + /** Return a const iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -579,7 +628,7 @@ public: const_iterator begin() const noexcept; - /** Return an iterator to the first element + /** Return a const iterator to the first element. If the container is empty, the returned iterator will be equal to @ref end(). @@ -592,7 +641,7 @@ public: const_iterator cbegin() const noexcept; - /** Return an iterator to the element following the last element + /** Return an iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -605,7 +654,7 @@ public: iterator end() noexcept; - /** Return an iterator to the element following the last element + /** Return a const iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -618,7 +667,7 @@ public: const_iterator end() const noexcept; - /** Return an iterator to the element following the last element + /** Return a const iterator to the element following the last element. The element acts as a placeholder; attempting to access it results in undefined behavior. @@ -631,7 +680,7 @@ public: const_iterator cend() const noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -645,7 +694,7 @@ public: reverse_iterator rbegin() noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a const reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -659,7 +708,7 @@ public: const_reverse_iterator rbegin() const noexcept; - /** Return a reverse iterator to the first element of the reversed container + /** Return a const reverse iterator to the first element of the reversed container. The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, @@ -673,7 +722,7 @@ public: const_reverse_iterator crbegin() const noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -688,7 +737,7 @@ public: reverse_iterator rend() noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a const reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -703,7 +752,7 @@ public: const_reverse_iterator rend() const noexcept; - /** Return a reverse iterator to the element following the last element of the reversed container + /** Return a const reverse iterator to the element following the last element of the reversed container. The pointed-to element corresponds to the element preceding the first element of the non-reversed container. @@ -1074,10 +1123,10 @@ public: std::size_t erase(key_type key) noexcept; - /** Swap the contents + /** Swap the contents. - Exchanges the contents of this container with another - container. Ownership of the respective @ref storage + Exchanges the contents of this object with another + object. Ownership of the respective @ref storage objects is not transferred. @li If `*other.get_storage() == *sp`, ownership of the @@ -1098,7 +1147,7 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to swap with + @param other The object to swap with. */ BOOST_JSON_DECL void @@ -1332,6 +1381,19 @@ private: } }; +/** Exchange the given values. + + @par Preconditions + + `&lhs != &rhs` +*/ +inline +void +swap(object& lhs, object& rhs) +{ + lhs.swap(rhs); +} + } // json } // boost diff --git a/include/boost/json/parser.hpp b/include/boost/json/parser.hpp index b1f1c0f3..ae2afc7b 100644 --- a/include/boost/json/parser.hpp +++ b/include/boost/json/parser.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_PARSER_HPP #define BOOST_JSON_PARSER_HPP -#include +#include #include #include #include diff --git a/include/boost/json/serializer.hpp b/include/boost/json/serializer.hpp index fe67d9a8..0cc7f51c 100644 --- a/include/boost/json/serializer.hpp +++ b/include/boost/json/serializer.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_SERIALIZER_HPP #define BOOST_JSON_SERIALIZER_HPP -#include +#include #include #include #include diff --git a/include/boost/json/src.hpp b/include/boost/json/src.hpp index 6ad821c3..2c5b74a0 100644 --- a/include/boost/json/src.hpp +++ b/include/boost/json/src.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,7 +17,7 @@ the program, with the macro BOOST_BEAST_SPLIT_COMPILATION defined. */ -#include +#include #if defined(BOOST_JSON_HEADER_ONLY) # error Do not compile library source with the header only macro defined diff --git a/include/boost/json/storage.hpp b/include/boost/json/storage.hpp index 83b49f17..9bfdae62 100644 --- a/include/boost/json/storage.hpp +++ b/include/boost/json/storage.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_STORAGE_HPP #define BOOST_JSON_STORAGE_HPP -#include +#include #include #include #include // for ::max_align_t @@ -72,19 +72,13 @@ public: bool operator==( storage const& lhs, - storage const& rhs) noexcept - { - return lhs.is_equal(rhs); - } + storage const& rhs) noexcept; friend bool operator!=( storage const& lhs, - storage const& rhs) noexcept - { - return ! lhs.is_equal(rhs); - } + storage const& rhs) noexcept; // Choose a unique 64-bit random number from here: // https://www.random.org/cgi-bin/randbyte?nbytes=8&format=h @@ -101,6 +95,28 @@ public: } }; +/** Return true if lhs equals rhs. +*/ +inline +bool +operator==( + storage const& lhs, + storage const& rhs) noexcept +{ + return lhs.is_equal(rhs); +} + +/** Return true if two values are not equal. +*/ +inline +bool +operator!=( + storage const& lhs, + storage const& rhs) noexcept +{ + return ! lhs.is_equal(rhs); +} + } // json } // boost diff --git a/include/boost/json/storage_ptr.hpp b/include/boost/json/storage_ptr.hpp index ab7c0cdf..f79e2759 100644 --- a/include/boost/json/storage_ptr.hpp +++ b/include/boost/json/storage_ptr.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_STORAGE_PTR_HPP #define BOOST_JSON_STORAGE_PTR_HPP -#include +#include #include #include #include @@ -267,33 +267,36 @@ public: return *get(); } - /** Create a new storage object and return a pointer to it. - - This functions similarly to `make_shared`. - - @par Mandates - - `std::is_base_of_v` - - @par Complexity - - Same as `U(std::forward(args)...)`. - - @par Exception Safety - - Strong guarantee. - - @param args Parameters forwarded to the constructor of `U`. - - @tparam U the type of the storage object to create. - */ template friend storage_ptr make_storage(Args&&... args); }; -#ifndef GENERATING_DOCUMENTATION +/** Create a new storage object and return a pointer to it. + + This functions similarly to `make_shared`. + + @par Mandates + + `std::is_base_of_v` + + @par Complexity + + Same as `T(std::forward(args)...)`. + + @par Exception Safety + + Strong guarantee. + + @param args Parameters forwarded to the constructor of `T`. + + @tparam T the type of the storage object to create. +*/ +template +storage_ptr +make_storage(Args&&... args); + inline bool operator==( @@ -311,7 +314,6 @@ operator!=( { return lhs.get() != rhs.get(); } -#endif //---------------------------------------------------------- diff --git a/include/boost/json/string.hpp b/include/boost/json/string.hpp index fbbc6423..d7f99988 100644 --- a/include/boost/json/string.hpp +++ b/include/boost/json/string.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_STRING_HPP #define BOOST_JSON_STRING_HPP -#include +#include #include #include #include @@ -2223,6 +2223,36 @@ public: //------------------------------------------------------ + /** Swap the contents. + + Exchanges the contents of this string with another + string. Ownership of the respective @ref storage + objects is not transferred. + + @li If `*other.get_storage() == *sp`, ownership of the + underlying memory is swapped in constant time, with + no possibility of exceptions. All iterators and + references remain valid. + + @li If `*other.get_storage() != *sp`, the contents are + logically swapped by making a copy, which can throw. + In this case all iterators and references are invalidated. + + @par Preconditions + + `&other != this` + + @par Complexity + + Constant or linear in @ref size() plus `other.size()`. + + @par Exception Safety + + Strong guarantee. + Calls to @ref storage::allocate may throw. + + @param other The string to swap with + */ BOOST_JSON_DECL void swap(string& other); @@ -2565,6 +2595,12 @@ private: //---------------------------------------------------------- +/** Exchange the given values. + + @par Preconditions + + `&lhs != &rhs` +*/ inline void swap(string& lhs, string& rhs) @@ -2574,176 +2610,284 @@ swap(string& lhs, string& rhs) //---------------------------------------------------------- -// operator== +/** Return true if lhs equals rhs. -inline + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator==(string const& lhs, string const& rhs) +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type +#endif +operator==(string const& lhs, T const& rhs) noexcept { return string_view(lhs) == string_view(rhs); } -template +/** Return true if lhs equals rhs. + + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type #endif -> -bool operator==(string const& lhs, T const& rhs) +operator==(T const& lhs, string const& rhs) noexcept { return string_view(lhs) == string_view(rhs); } -template -#endif -> -bool operator==(T const& lhs, string const& rhs) -{ - return string_view(lhs) == string_view(rhs); -} +/** Return true if lhs does not equal rhs. -// operator!= + A lexicographical comparison is used. -inline + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator!=(string const& lhs, string const& rhs) +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type +#endif +operator!=(string const& lhs, T const& rhs) noexcept { return string_view(lhs) != string_view(rhs); } -template +/** Return true if lhs does not equal rhs. + + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type #endif -> -bool operator!=(string const& lhs, T const& rhs) +operator!=(T const& lhs, string const& rhs) noexcept { return string_view(lhs) != string_view(rhs); } -template -#endif -> -bool operator!=(T const& lhs, string const& rhs) -{ - return string_view(lhs) != string_view(rhs); -} +/** Return true if lhs is less than rhs. -// operator< + A lexicographical comparison is used. -inline + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator<(string const& lhs, string const& rhs) +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type +#endif +operator<(string const& lhs, T const& rhs) noexcept { return string_view(lhs) < string_view(rhs); } -template +/** Return true if lhs is less than rhs. + + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type #endif -> -bool operator<(string const& lhs, T const& rhs) +operator<(T const& lhs, string const& rhs) noexcept { return string_view(lhs) < string_view(rhs); } -template -#endif -> -bool operator<(T const& lhs, string const& rhs) -{ - return string_view(lhs) < string_view(rhs); -} +/** Return true if lhs is less than or equal to rhs. -// operator<= + A lexicographical comparison is used. -inline + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator<=(string const& lhs, string const& rhs) +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type +#endif +operator<=(string const& lhs, T const& rhs) noexcept { return string_view(lhs) <= string_view(rhs); } -template +/** Return true if lhs is less than or equal to rhs. + + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type #endif -> -bool operator<=(string const& lhs, T const& rhs) +operator<=(T const& lhs, string const& rhs) noexcept { return string_view(lhs) <= string_view(rhs); } -template -#endif -> -bool operator<=(T const& lhs, string const& rhs) -{ - return string_view(lhs) <= string_view(rhs); -} +/** Return true if lhs is greater than or equal to rhs. -// operator>= + A lexicographical comparison is used. -inline + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator>=(string const& lhs, string const& rhs) -{ - return string_view(lhs) >= string_view(rhs); -} - -template +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type #endif -> -bool operator>=(string const& lhs, T const& rhs) +operator>=(string const& lhs, T const& rhs) noexcept { return string_view(lhs) >= string_view(rhs); } -template -#endif -> -bool operator>=(T const& lhs, string const& rhs) -{ - return string_view(lhs) >= string_view(rhs); -} +/** Return true if lhs is greater than or equal to rhs. -// operator>= + A lexicographical comparison is used. -inline + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION bool -operator>(string const& lhs, string const& rhs) +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type +#endif +operator>=(T const& lhs, string const& rhs) noexcept +{ + return string_view(lhs) >= string_view(rhs); +} + +/** Return true if lhs is greater than rhs. + + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value, + bool>::type +#endif +operator>(string const& lhs, T const& rhs) noexcept { return string_view(lhs) > string_view(rhs); } -template -#endif -> -bool operator>(string const& lhs, T const& rhs) -{ - return string_view(lhs) > string_view(rhs); -} +/** Return true if lhs equals rhs. -template + A lexicographical comparison is used. + + @par Constraints + @code + std::is_convertible_v && ! std::is_base_of_v + @endcode +*/ +template +#ifdef GENERATING_DOCUMENTATION +bool +#else +typename std::enable_if< + std::is_convertible< + T const&, string_view>::value && + ! std::is_base_of::value, + bool>::type #endif -> -bool operator>(T const& lhs, string const& rhs) +operator>(T const& lhs, string const& rhs) noexcept { return string_view(lhs) > string_view(rhs); } diff --git a/include/boost/json/value.hpp b/include/boost/json/value.hpp index 52cc8e41..92dcf9b5 100644 --- a/include/boost/json/value.hpp +++ b/include/boost/json/value.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #ifndef BOOST_JSON_VALUE_HPP #define BOOST_JSON_VALUE_HPP -#include +#include #include #include #include @@ -140,7 +140,7 @@ public: @par Complexity - Linear in the size of `*this`. + Constant, or linear in size for array or object. */ BOOST_JSON_DECL ~value(); @@ -153,9 +153,8 @@ public: /** Default constructor. - Default constructed values are null. - The container and all of its contents will use the - default storage. + The constructed value is null, + using the default storage. @par Complexity @@ -172,9 +171,8 @@ public: /** Constructor. - Construct a null value. - The container and all of its contents will use the - specified storage. + The constructed value is null, + using the specified storage. @par Complexity @@ -184,7 +182,9 @@ public: No-throw guarantee. - @param sp The storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ explicit value(storage_ptr sp) noexcept @@ -194,13 +194,12 @@ public: /** Pilfer constructor. - Constructs the container with the contents - of `other` using pilfer semantics. - Ownership of the storage is transferred. + The value is constructed by acquiring ownership of + the contents of `other` using pilfer semantics. @note - After construction, the moved-from object may + After construction, the moved-from value may only be destroyed. @par Complexity @@ -211,7 +210,7 @@ public: No-throw guarantee. - @param other The container to pilfer. + @param other The value to pilfer. @see @@ -223,8 +222,8 @@ public: /** Copy constructor. - The container and all of its contents will use - the same storage as `other`. + The value is constructed with a copy of the + contents of `other`, using the storage of `other`. @par Complexity @@ -244,8 +243,8 @@ public: /** Copy constructor - The container and all of its contents will use the - specified storage. + The value is constructed with a copy of the + contents of `other`, using the specified storage. @par Complexity @@ -253,7 +252,9 @@ public: @param other The value to copy. - @param sp The storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL value( @@ -262,12 +263,15 @@ public: /** Move constructor - Constructs the container with the contents of `other` - using move semantics. Ownership of the underlying - memory is transferred. - The container acquires shared ownership of the - storage used by `other`. + The value is constructed by acquiring ownership of + the contents of `other` and shared ownership of + the storage of `other`. + @note + + After construction, the moved-from value becomes a + null value with its current storage pointer. + @par Complexity Constant. @@ -283,18 +287,21 @@ public: /** Move constructor - Using `*sp` as the storage for the new container, - moves all the elements from `other`. + The value is constructed with the contents of + `other` by move semantics, using the specified + storage: - @li If `*other.get_storage() == *sp`, ownership of the - underlying memory is transferred in constant time, with - no possibility of exceptions. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. + After construction, the moved-from value becomes + a null value with its current storage pointer. - @li If `*other.get_storage() != *sp`, a copy is performed. - In this case, the moved-from container is not changed. - - The container and all of its contents will use the - specified storage object. + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed if + `other.is_structured() == true`, which may throw. + In this case, the moved-from value is not + changed. @par Complexity @@ -305,31 +312,40 @@ public: Strong guarantee. Calls to @ref storage::allocate may throw. - @param other The container to move. + @param other The value to move. - @param sp The storage to use. + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL value( value&& other, storage_ptr sp); - /** Move assignment operator + //------------------------------------------------------ - Replaces the contents with those of `other` using move - semantics (the data in `other` is moved into this container). + /** Move assignment. - @li If `*other.get_storage() == get_storage()`, - ownership of the underlying memory is transferred in - constant time, with no possibility of exceptions. + The contents of the value are replaced with the + contents of `other` using move semantics: - @li If `*other.get_storage() != *sp`, a copy is performed. - In this case the moved-from container is not modified, - and exceptions may be thrown. + @li If `*other.get_storage() == *sp`, ownership of + the underlying memory is transferred in constant + time, with no possibility of exceptions. + After assignment, the moved-from value becomes + a null with its current storage pointer. + + @li If `*other.get_storage() != *sp`, an + element-wise copy is performed if + `other.is_structured() == true`, which may throw. + In this case, the moved-from value is not + changed. @par Complexity - Constant or linear in the size of `*this` plus `other`. + Constant, or linear in + `this->size()` plus `other.size()`. @par Exception Safety @@ -343,7 +359,8 @@ public: /** Copy assignment operator - Replaces the contents with a copy of `other`. + The contents of the value are replaced with an + element-wise copy of the contents of `other`. @par Complexity @@ -365,14 +382,14 @@ public: // //------------------------------------------------------ - /** Construct an object. + /** Construct an @ref object. */ value(object obj) noexcept : obj_(detail::move(obj)) { } - /** Construct an object. + /** Construct an @ref object. */ value( object obj, @@ -383,7 +400,35 @@ public: { } - /** Construct an object. + /** Construct an @ref object. + + This is the fastest way to construct + an empty object, using the specified + storage. The variable @ref object_kind + may be passed as the first parameter + to select this overload: + + @par Example + + @code + // Construct an empty object + + value jv( object_kind ); + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. + + @see object_kind */ value( object_kind_t, @@ -392,14 +437,14 @@ public: { } - /** Construct an array. + /** Construct an @ref array. */ value(array arr) noexcept : arr_(detail::move(arr)) { } - /** Construct an array. + /** Construct an @ref array. */ value( array arr, @@ -410,7 +455,35 @@ public: { } - /** Construct an array. + /** Construct an @ref array. + + This is the fastest way to construct + an empty array, using the specified + storage. The variable @ref array_kind + may be passed as the first parameter + to select this overload: + + @par Example + + @code + // Construct an empty array + + value jv( array_kind ); + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. + + @see array_kind */ value( array_kind_t, @@ -419,7 +492,18 @@ public: { } - /** Construct a string. + /** Construct a @ref string. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param str The initial value. + */ value( string str) noexcept @@ -427,7 +511,7 @@ public: { } - /** Construct a string. + /** Construct a @ref string. */ value( string str, @@ -438,7 +522,7 @@ public: { } - /** Construct a string. + /** Construct a @ref string. */ value( string_view s, @@ -447,7 +531,7 @@ public: { } - /** Construct a string. + /** Construct a @ref string. */ value( char const* s, @@ -456,110 +540,297 @@ public: { } - /** Construct an array. + /** Construct a @ref string. + + This is the fastest way to construct + an empty string, using the specified + storage. The variable @ref string_kind + may be passed as the first parameter + to select this overload: + + @par Example + + @code + // Construct an empty string + + value jv( string_kind ); + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. + + @see string_kind */ - value(string_kind_t, + value( + string_kind_t, storage_ptr sp = {}) noexcept : str_(detail::move(sp)) { } - /** Construct a signed integer. + /** Construct a `std::int64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param i The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( short i, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : i64_(i, detail::move(sp)) { } - /** Construct a signed integer. + /** Construct a `std::int64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param i The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( int i, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : i64_(i, detail::move(sp)) { } - /** Construct a signed integer. + /** Construct a `std::int64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param i The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( long i, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : i64_(i, detail::move(sp)) { } - /** Construct a signed integer. + /** Construct a `std::int64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param i The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( long long i, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : i64_(i, detail::move(sp)) { } - /** Construct an unsigned integer. + /** Construct a `std::uint64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param u The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( unsigned short u, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : u64_(u, detail::move(sp)) { } - /** Construct an unsigned integer. + /** Construct a `std::uint64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param u The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( unsigned int u, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : u64_(u, detail::move(sp)) { } - /** Construct an unsigned integer. + /** Construct a `std::uint64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param u The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( unsigned long u, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : u64_(u, detail::move(sp)) { } - /** Construct an unsigned integer. + /** Construct a `std::uint64_t`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param u The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( unsigned long long u, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : u64_(u, detail::move(sp)) { } - /** Construct a floating point number. + /** Construct a `double`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param d The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( double d, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : dub_(d, detail::move(sp)) { } - /** Construct a floating point number. + /** Construct a `double`. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param d The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ value( long double d, - storage_ptr sp = {}) + storage_ptr sp = {}) noexcept : dub_(static_cast(d), detail::move(sp)) { } - /** Construct a boolean. + /** Construct a bool. + + This constructs a `bool` value using + the specified storage. + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + + @param b The initial value. + + @param sp A pointer to the @ref storage + to use. The container will acquire shared + ownership of the storage object. */ #ifdef GENERATING_DOCUMENTATION - value(bool b, - storage_ptr = {}) noexcept; + value( + bool b, + storage_ptr sp = {}) noexcept; #else templateis_object()` */ object& as_object() @@ -1315,11 +1776,11 @@ public: return obj_; } - /** Return a reference to the object, or throw an exception. + /** Return a reference to the underlying `object`, or throw an exception. - If @ref kind() returns `kind::object`, - returns a reference to the object. Otherwise, - throws an exception. + If @ref is_object() is `true`, returns + a reference to the underlying @ref object, + otherwise throws an exception. @par Complexity @@ -1329,7 +1790,7 @@ public: Strong guarantee. - @throw system_error if `*this` is not an object. + @throw system_error `! this->is_object()` */ object const& as_object() const @@ -1341,11 +1802,11 @@ public: return obj_; } - /** Return a reference to the array, or throw an exception. + /** Return a reference to the underlying `array`, or throw an exception. - If @ref kind() returns `kind::array`, - returns a reference to the array. Otherwise, - throws an exception. + If @ref is_array() is `true`, returns + a reference to the underlying @ref array, + otherwise throws an exception. @par Complexity @@ -1355,7 +1816,7 @@ public: Strong guarantee. - @throw system_error if `*this` is not an array. + @throw system_error `! this->is_array()` */ array& as_array() @@ -1367,11 +1828,11 @@ public: return arr_; } - /** Return a reference to the array, or throw an exception. + /** Return a reference to the underlying `array`, or throw an exception. - If @ref kind() returns `kind::array`, - returns a reference to the array. Otherwise, - throws an exception. + If @ref is_array() is `true`, returns + a reference to the underlying @ref array, + otherwise throws an exception. @par Complexity @@ -1381,7 +1842,7 @@ public: Strong guarantee. - @throw system_error if `*this` is not an array. + @throw system_error `! this->is_array()` */ array const& as_array() const @@ -1393,11 +1854,11 @@ public: return arr_; } - /** Return a reference to the string, or throw an exception. + /** Return a reference to the underlying `string`, or throw an exception. - If @ref kind() returns `kind::string`, - returns a reference to the string. Otherwise, - throws an exception. + If @ref is_string() is `true`, returns + a reference to the underlying @ref string, + otherwise throws an exception. @par Complexity @@ -1407,7 +1868,7 @@ public: Strong guarantee. - @throw system_error if `*this` is not a string. + @throw system_error `! this->is_string()` */ string& as_string() @@ -1419,11 +1880,11 @@ public: return str_; } - /** Return a reference to the string, or throw an exception. + /** Return a reference to the underlying `string`, or throw an exception. - If @ref kind() returns `kind::string`, - returns a reference to the string. Otherwise, - throws an exception. + If @ref is_string() is `true`, returns + a reference to the underlying @ref string, + otherwise throws an exception. @par Complexity @@ -1433,7 +1894,7 @@ public: Strong guarantee. - @throw system_error if `*this` is not a string. + @throw system_error `! this->is_string()` */ string const& as_string() const @@ -1445,6 +1906,22 @@ public: return str_; } + /** Return a reference to the underlying `std::int64_t`, or throw an exception. + + If @ref is_int64() is `true`, returns + a reference to the underlying `std::int64_t`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_int64()` + */ std::int64_t& as_int64() { @@ -1455,8 +1932,23 @@ public: return i64_.i; } + /** Return the underlying `std::int64_t`, or throw an exception. - std::int64_t const& + If @ref is_int64() is `true`, returns + the underlying `std::int64_t`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_int64()` + */ + std::int64_t as_int64() const { if(! is_int64()) @@ -1466,6 +1958,22 @@ public: return i64_.i; } + /** Return a reference to the underlying `std::uint64_t`, or throw an exception. + + If @ref is_uint64() is `true`, returns + a reference to the underlying `std::uint64_t`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_uint64()` + */ std::uint64_t& as_uint64() { @@ -1477,7 +1985,23 @@ public: } - std::uint64_t const& + /** Return the underlying `std::uint64_t`, or throw an exception. + + If @ref is_int64() is `true`, returns + the underlying `std::uint64_t`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_uint64()` + */ + std::uint64_t as_uint64() const { if(! is_uint64()) @@ -1487,6 +2011,22 @@ public: return u64_.u; } + /** Return a reference to the underlying `double`, or throw an exception. + + If @ref is_double() is `true`, returns + a reference to the underlying `double`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_double()` + */ double& as_double() { @@ -1497,22 +2037,11 @@ public: return dub_.d; } + /** Return the underlying `double`, or throw an exception. - double const& - as_double() const - { - if(! is_double()) - BOOST_JSON_THROW( - system_error( - error::not_number)); - return dub_.d; - } - - /** Return a reference to the bool, or throw an exception. - - If @ref kind() returns `kind::boolean`, - returns a reference to the `bool`. Otherwise, - throws an exception. + If @ref is_int64() is `true`, returns + the underlying `double`, + otherwise throws an exception. @par Complexity @@ -1522,7 +2051,33 @@ public: Strong guarantee. - @throw system_error if `*this` is not a boolean. + @throw system_error `! this->is_double()` + */ + double + as_double() const + { + if(! is_double()) + BOOST_JSON_THROW( + system_error( + error::not_number)); + return dub_.d; + } + + /** Return a reference to the underlying `bool`, or throw an exception. + + If @ref is_bool() is `true`, returns + a reference to the underlying `bool`, + otherwise throws an exception. + + @par Complexity + + Constant. + + @par Exception Safety + + Strong guarantee. + + @throw system_error `! this->is_bool()` */ bool& as_bool() @@ -1534,11 +2089,11 @@ public: return bln_.b; } - /** Return a reference to the bool, or throw an exception. + /** Return the underlying `bool`, or throw an exception. - If @ref kind() returns `kind::boolean`, - returns a reference to the `bool`. Otherwise, - throws an exception. + If @ref is_bool() is `true`, returns + the underlying `bool`, + otherwise throws an exception. @par Complexity @@ -1548,9 +2103,9 @@ public: Strong guarantee. - @throw system_error if `*this` is not a boolean. + @throw system_error `! this->is_bool()` */ - bool const& + bool as_bool() const { if(! is_bool()) @@ -1562,10 +2117,10 @@ public: //------------------------------------------------------ - /** Return a value as an object, without checking. + /** Return a reference to the underlying `object`, without checking. - This is a fast way to gain access to an object - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1588,10 +2143,10 @@ public: return obj_; } - /** Return a value as an object, without checking. + /** Return a reference to the underlying `object`, without checking. - This is a fast way to gain access to an object - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1614,10 +2169,10 @@ public: return obj_; } - /** Return a value as an array, without checking. + /** Return a reference to the underlying `array`, without checking. - This is a fast way to gain access to an array - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1640,10 +2195,10 @@ public: return arr_; } - /** Return a value as an array, without checking. + /** Return a reference to the underlying `array`, without checking. - This is a fast way to gain access to an array - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1666,10 +2221,10 @@ public: return arr_; } - /** Return a value as a string, without checking. + /** Return a reference to the underlying `string`, without checking. - This is a fast way to gain access to a string - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1692,10 +2247,10 @@ public: return str_; } - /** Return a value as a string, without checking. + /** Return a reference to the underlying `string`, without checking. - This is a fast way to gain access to a string - value when the kind is known. + This is the fastest way to access the underlying + representation when the kind is known in advance. @par Preconditions @@ -1718,6 +2273,214 @@ public: return str_; } + /** Return a reference to the underlying `std::int64_t`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_int64() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + std::int64_t& + get_int64() noexcept + { + BOOST_JSON_ASSERT(is_int64()); + return i64_.i; + } + + /** Return the underlying `std::int64_t`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_int64() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + std::int64_t + get_int64() const noexcept + { + BOOST_JSON_ASSERT(is_int64()); + return i64_.i; + } + + /** Return a reference to the underlying `std::uint64_t`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_uint64() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + std::uint64_t& + get_uint64() noexcept + { + BOOST_JSON_ASSERT(is_uint64()); + return u64_.u; + } + + /** Return the underlying `std::uint64_t`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_uint64() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + std::uint64_t + get_uint64() const noexcept + { + BOOST_JSON_ASSERT(is_uint64()); + return u64_.u; + } + + /** Return a reference to the underlying `double`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_double() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + double& + get_double() noexcept + { + BOOST_JSON_ASSERT(is_double()); + return dub_.d; + } + + /** Return the underlying `double`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_double() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + double + get_double() const noexcept + { + BOOST_JSON_ASSERT(is_double()); + return dub_.d; + } + + /** Return a reference to the underlying `bool`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_bool() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + bool& + get_bool() noexcept + { + BOOST_JSON_ASSERT(is_bool()); + return bln_.b; + } + + /** Return the underlying `bool`, without checking. + + This is the fastest way to access the underlying + representation when the kind is known in advance. + + @par Preconditions + + @code + this->is_bool() + @endcode + + @par Complexity + + Constant. + + @par Exception Safety + + No-throw guarantee. + */ + bool + get_bool() const noexcept + { + BOOST_JSON_ASSERT(is_bool()); + return bln_.b; + } + //------------------------------------------------------ private: @@ -1728,51 +2491,103 @@ private: //---------------------------------------------------------- +/** Exchange the given values. + + @par Preconditions + + `&lhs != &rhs` +*/ +inline +void +swap(value& lhs, value& rhs) +{ + lhs.swap(rhs); +} + +//---------------------------------------------------------- + /** A key/value pair. This is the type of element stored in the @ref object container. */ -struct object_value_type +struct key_value_pair { /** Copy assignment (deleted). */ - object_value_type& - operator=(object_value_type const&) = delete; + key_value_pair& + operator=(key_value_pair const&) = delete; /** Destructor. + + The value is destroyed and all internal + storage is freed. */ BOOST_JSON_DECL - ~object_value_type(); + ~key_value_pair(); /** Copy constructor. + + This constructs a key/value pair with a + copy of another key/value pair, using + the same storage as `other`. + + @param other The key/value pair to copy. */ BOOST_JSON_DECL - object_value_type(object_value_type const& other); + key_value_pair(key_value_pair const& other); /** Copy constructor. + + This constructs a key/value pair with a + copy of another key/value pair, using + the specified storage. + + @param other The key/value pair to copy. + + @param sp A pointer to the @ref storage + to use. The element will acquire shared + ownership of the storage object. */ BOOST_JSON_DECL - object_value_type( - object_value_type const& other, + key_value_pair( + key_value_pair const& other, storage_ptr sp); - /** Construct a key and value pair. + /** Constructor. + + This constructs a key/value pair. + + @param key The key string to use. + + @param args Optional arguments forwarded to + the @ref value constructor. */ template - object_value_type( + key_value_pair( string_view key, Args&&... args); - /** Construct a key and value pair. + /** Constructor. + + This constructs a key/value pair. A + copy of the specified value is made, + using the specified storage. + + @param p A `std::pair` with the key + string and @ref value to construct with. + + @param sp A pointer to the @ref storage + to use. The element will acquire shared + ownership of the storage object. */ explicit - object_value_type( + key_value_pair( std::pair< string_view, json::value> const& p, storage_ptr sp = {}) - : object_value_type( + : key_value_pair( p.first, p.second, detail::move(sp)) @@ -1780,14 +2595,25 @@ struct object_value_type } /** Construct a key and value pair. + + This constructs a key/value pair. + Ownership of the specified value is + transferred by move construction. + + @param p A `std::pair` with the key + string and @ref value to construct with. + + @param sp A pointer to the @ref storage + to use. The element will acquire shared + ownership of the storage object. */ explicit - object_value_type( + key_value_pair( std::pair< string_view, json::value>&& p, storage_ptr sp = {}) - : object_value_type( + : key_value_pair( p.first, detail::move(p).second, detail::move(sp)) @@ -1795,6 +2621,9 @@ struct object_value_type } /** Return the key of this element. + + After construction, the key may + not be modified. */ string_view const key() const noexcept @@ -1818,19 +2647,13 @@ struct object_value_type return value_; } - /** Destroy a range of elements. - */ - BOOST_JSON_DECL - static - void - destroy( - object_value_type* p, - std::size_t n) noexcept; - private: +#ifndef GENERATING_DOCUMENTATION + // docca emits this when it shouldn't friend struct detail::next_access; +#endif - object_value_type* next_; + key_value_pair* next_; json::value value_; std::size_t len_; char* key_; diff --git a/include/boost/pilfer.hpp b/include/boost/pilfer.hpp index 53f7cd3b..a7805442 100644 --- a/include/boost/pilfer.hpp +++ b/include/boost/pilfer.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/src/src.cpp b/src/src.cpp index 516d5f0a..1faab23c 100644 --- a/src/src.cpp +++ b/src/src.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 10f61dfb..705b9ddd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/Jamfile b/test/Jamfile index 6dbe312e..d859be2a 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2019 Vinnie Falco (vinnie.falco@gmail.com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/array.cpp b/test/array.cpp index d691fbf4..3018f228 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/assign_string.cpp b/test/assign_string.cpp index 921dec43..bbb6705e 100644 --- a/test/assign_string.cpp +++ b/test/assign_string.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -22,6 +22,7 @@ public: void testAssign() { + #if ! defined(_MSC_VER) || _MSC_VER >= 1910 value jv = "test"; std::string s; try @@ -33,9 +34,13 @@ public: { BEAST_FAIL(); } + #else + pass(); + #endif } - void run() override + void + run() override { testAssign(); } diff --git a/test/assign_vector.cpp b/test/assign_vector.cpp index e2539ef7..e6188ffa 100644 --- a/test/assign_vector.cpp +++ b/test/assign_vector.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,14 +19,15 @@ namespace json { class assign_vector_test : public beast::unit_test::suite { public: - BOOST_JSON_STATIC_ASSERT( - has_from_json::value); - BOOST_JSON_STATIC_ASSERT( - detail::has_adl_from_json>::value); - void testAssign() { + #if ! defined(_MSC_VER) || _MSC_VER >= 1910 + BOOST_JSON_STATIC_ASSERT( + has_from_json::value); + BOOST_JSON_STATIC_ASSERT( + detail::has_adl_from_json>::value); + value jv(array{}); { auto& a = jv.as_array(); @@ -47,9 +48,13 @@ public: { BEAST_FAIL(); } + #else + pass(); + #endif } - void run() override + void + run() override { testAssign(); } diff --git a/test/basic_parser.cpp b/test/basic_parser.cpp index e7e0a3c7..e2341dca 100644 --- a/test/basic_parser.cpp +++ b/test/basic_parser.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/block_storage.cpp b/test/block_storage.cpp index cf369749..671429dc 100644 --- a/test/block_storage.cpp +++ b/test/block_storage.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/error.cpp b/test/error.cpp index 6aaada22..bd10faf1 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/json.cpp b/test/json.cpp index 16acc796..d971aae3 100644 --- a/test/json.cpp +++ b/test/json.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/kind.cpp b/test/kind.cpp index 1a5b3ddb..290b4063 100644 --- a/test/kind.cpp +++ b/test/kind.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/limits.cpp b/test/limits.cpp index 20b3749c..ca827339 100644 --- a/test/limits.cpp +++ b/test/limits.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/main.cpp b/test/main.cpp index a7f0cf41..cad92c74 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/number.cpp b/test/number.cpp index 43148c79..62e5d80b 100644 --- a/test/number.cpp +++ b/test/number.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/object.cpp b/test/object.cpp index 2e83e367..8ec88951 100644 --- a/test/object.cpp +++ b/test/object.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/parse-vectors.hpp b/test/parse-vectors.hpp index c1bec483..f235a9c0 100644 --- a/test/parse-vectors.hpp +++ b/test/parse-vectors.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/parser.cpp b/test/parser.cpp index caff2796..9e03b97a 100644 --- a/test/parser.cpp +++ b/test/parser.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/ryu/gtest.hpp b/test/ryu/gtest.hpp index b14a9700..79566570 100644 --- a/test/ryu/gtest.hpp +++ b/test/ryu/gtest.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/serializer.cpp b/test/serializer.cpp index 3afd9852..32e33ef1 100644 --- a/test/serializer.cpp +++ b/test/serializer.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/storage.cpp b/test/storage.cpp index 594a15cb..f03a3dbe 100644 --- a/test/storage.cpp +++ b/test/storage.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/storage_ptr.cpp b/test/storage_ptr.cpp index 3e3098d1..55e41b56 100644 --- a/test/storage_ptr.cpp +++ b/test/storage_ptr.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/string.cpp b/test/string.cpp index 4d97ac80..afe8de08 100644 --- a/test/string.cpp +++ b/test/string.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -2600,58 +2600,84 @@ public: string const s2(t.v2); auto const v1(t.v1); auto const v2(t.v2); + auto const c1 = t.s1.c_str(); + auto const c2 = t.s2.c_str(); BEAST_EXPECT(! operator< (s1, s2)); BEAST_EXPECT(! operator< (s1, v2)); + BEAST_EXPECT(! operator< (s1, c2)); BEAST_EXPECT(! operator<=(s1, s2)); BEAST_EXPECT(! operator<=(s1, v2)); + BEAST_EXPECT(! operator<=(s1, c2)); BEAST_EXPECT(! operator==(s1, s2)); BEAST_EXPECT(! operator==(s1, v2)); + BEAST_EXPECT(! operator==(s1, c2)); BEAST_EXPECT( operator!=(s1, s2)); BEAST_EXPECT( operator!=(s1, v2)); + BEAST_EXPECT( operator!=(s1, c2)); BEAST_EXPECT( operator>=(s1, s2)); BEAST_EXPECT( operator>=(s1, v2)); + BEAST_EXPECT( operator>=(s1, c2)); BEAST_EXPECT( operator> (s1, s2)); BEAST_EXPECT( operator> (s1, v2)); + BEAST_EXPECT( operator> (s1, c2)); BEAST_EXPECT( operator< (s2, s1)); BEAST_EXPECT( operator< (s2, v1)); + BEAST_EXPECT( operator< (s2, c1)); BEAST_EXPECT( operator<=(s2, s1)); BEAST_EXPECT( operator<=(s2, v1)); + BEAST_EXPECT( operator<=(s2, c1)); BEAST_EXPECT( operator!=(s2, s1)); BEAST_EXPECT( operator!=(s2, v1)); + BEAST_EXPECT( operator!=(s2, c1)); BEAST_EXPECT(! operator==(s2, s1)); BEAST_EXPECT(! operator==(s2, v1)); + BEAST_EXPECT(! operator==(s2, c1)); BEAST_EXPECT(! operator>=(s2, s1)); BEAST_EXPECT(! operator>=(s2, v1)); + BEAST_EXPECT(! operator>=(s2, c1)); BEAST_EXPECT(! operator> (s2, s1)); BEAST_EXPECT(! operator> (s2, v1)); + BEAST_EXPECT(! operator> (s2, c1)); BEAST_EXPECT( operator< (s2, s1)); BEAST_EXPECT( operator< (v2, s1)); + BEAST_EXPECT( operator< (c2, s1)); BEAST_EXPECT( operator<=(s2, s1)); BEAST_EXPECT( operator<=(v2, s1)); + BEAST_EXPECT( operator<=(c2, s1)); BEAST_EXPECT( operator!=(s2, s1)); BEAST_EXPECT( operator!=(v2, s1)); + BEAST_EXPECT( operator!=(c2, s1)); BEAST_EXPECT(! operator==(s2, s1)); BEAST_EXPECT(! operator==(v2, s1)); + BEAST_EXPECT(! operator==(c2, s1)); BEAST_EXPECT(! operator>=(s2, s1)); BEAST_EXPECT(! operator>=(v2, s1)); + BEAST_EXPECT(! operator>=(c2, s1)); BEAST_EXPECT(! operator> (s2, s1)); BEAST_EXPECT(! operator> (v2, s1)); + BEAST_EXPECT(! operator> (c2, s1)); BEAST_EXPECT(! operator< (s1, s2)); BEAST_EXPECT(! operator< (v1, s2)); + BEAST_EXPECT(! operator< (c1, s2)); BEAST_EXPECT(! operator<=(s1, s2)); BEAST_EXPECT(! operator<=(v1, s2)); + BEAST_EXPECT(! operator<=(c1, s2)); BEAST_EXPECT(! operator==(s1, s2)); BEAST_EXPECT(! operator==(v1, s2)); + BEAST_EXPECT(! operator==(c1, s2)); BEAST_EXPECT( operator!=(s1, s2)); BEAST_EXPECT( operator!=(v1, s2)); + BEAST_EXPECT( operator!=(c1, s2)); BEAST_EXPECT( operator>=(s1, s2)); BEAST_EXPECT( operator>=(v1, s2)); + BEAST_EXPECT( operator>=(c1, s2)); BEAST_EXPECT( operator> (s1, s2)); BEAST_EXPECT( operator> (v1, s2)); + BEAST_EXPECT( operator> (c1, s2)); std::stringstream ss; string s = "Hello, world"; diff --git a/test/test.hpp b/test/test.hpp index 950c4c6f..403d4fe3 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -575,7 +575,7 @@ equal_storage( case json::kind::int64: case json::kind::uint64: case json::kind::double_: - case json::kind::boolean: + case json::kind::bool_: case json::kind::null: break; } @@ -711,7 +711,7 @@ to_string_test( break; } - case kind::boolean: + case kind::bool_: if(jv.as_bool()) dest.append("true"); else @@ -817,7 +817,7 @@ equal( *lhs.if_uint64() == *rhs.if_uint64(); - case kind::boolean: + case kind::bool_: return *lhs.if_bool() == *rhs.if_bool(); diff --git a/test/value.cpp b/test/value.cpp index 222a7f91..3b2ff789 100644 --- a/test/value.cpp +++ b/test/value.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -896,7 +896,7 @@ public: value const i64(std::int64_t{}); value const u64(std::uint64_t{}); value const dub(double{}); - value const boo(true); + value const bln(true); value const nul(nullptr); // kind() @@ -907,7 +907,7 @@ public: BEAST_EXPECT(i64.kind() == kind::int64); BEAST_EXPECT(u64.kind() == kind::uint64); BEAST_EXPECT(dub.kind() == kind::double_); - BEAST_EXPECT(boo.kind() == kind::boolean); + BEAST_EXPECT(bln.kind() == kind::bool_); BEAST_EXPECT(nul.kind() == kind::null); } @@ -919,7 +919,7 @@ public: BEAST_EXPECT(! i64.is_object()); BEAST_EXPECT(! u64.is_object()); BEAST_EXPECT(! dub.is_object()); - BEAST_EXPECT(! boo.is_object()); + BEAST_EXPECT(! bln.is_object()); BEAST_EXPECT(! nul.is_object()); } @@ -931,7 +931,7 @@ public: BEAST_EXPECT(! i64.is_array()); BEAST_EXPECT(! u64.is_array()); BEAST_EXPECT(! dub.is_array()); - BEAST_EXPECT(! boo.is_array()); + BEAST_EXPECT(! bln.is_array()); BEAST_EXPECT(! nul.is_array()); } @@ -943,22 +943,10 @@ public: BEAST_EXPECT(! i64.is_string()); BEAST_EXPECT(! u64.is_string()); BEAST_EXPECT(! dub.is_string()); - BEAST_EXPECT(! boo.is_string()); + BEAST_EXPECT(! bln.is_string()); BEAST_EXPECT(! nul.is_string()); } - // is_number() - { - BEAST_EXPECT(! obj.is_number()); - BEAST_EXPECT(! arr.is_number()); - BEAST_EXPECT(! str.is_number()); - BEAST_EXPECT( i64.is_number()); - BEAST_EXPECT( u64.is_number()); - BEAST_EXPECT( dub.is_number()); - BEAST_EXPECT(! boo.is_number()); - BEAST_EXPECT(! nul.is_number()); - } - // is_int64() { BEAST_EXPECT(! obj.is_int64()); @@ -967,7 +955,7 @@ public: BEAST_EXPECT( i64.is_int64()); BEAST_EXPECT(! u64.is_int64()); BEAST_EXPECT(! dub.is_int64()); - BEAST_EXPECT(! boo.is_int64()); + BEAST_EXPECT(! bln.is_int64()); BEAST_EXPECT(! nul.is_int64()); } @@ -979,7 +967,7 @@ public: BEAST_EXPECT(! i64.is_uint64()); BEAST_EXPECT( u64.is_uint64()); BEAST_EXPECT(! dub.is_uint64()); - BEAST_EXPECT(! boo.is_uint64()); + BEAST_EXPECT(! bln.is_uint64()); BEAST_EXPECT(! nul.is_uint64()); } @@ -991,7 +979,7 @@ public: BEAST_EXPECT(! i64.is_double()); BEAST_EXPECT(! u64.is_double()); BEAST_EXPECT( dub.is_double()); - BEAST_EXPECT(! boo.is_double()); + BEAST_EXPECT(! bln.is_double()); BEAST_EXPECT(! nul.is_double()); } @@ -1003,7 +991,7 @@ public: BEAST_EXPECT(! i64.is_bool()); BEAST_EXPECT(! u64.is_bool()); BEAST_EXPECT(! dub.is_bool()); - BEAST_EXPECT( boo.is_bool()); + BEAST_EXPECT( bln.is_bool()); BEAST_EXPECT(! nul.is_bool()); } @@ -1015,10 +1003,22 @@ public: BEAST_EXPECT(! i64.is_null()); BEAST_EXPECT(! u64.is_null()); BEAST_EXPECT(! dub.is_null()); - BEAST_EXPECT(! boo.is_null()); + BEAST_EXPECT(! bln.is_null()); BEAST_EXPECT( nul.is_null()); } + // is_number() + { + BEAST_EXPECT(! obj.is_number()); + BEAST_EXPECT(! arr.is_number()); + BEAST_EXPECT(! str.is_number()); + BEAST_EXPECT( i64.is_number()); + BEAST_EXPECT( u64.is_number()); + BEAST_EXPECT( dub.is_number()); + BEAST_EXPECT(! bln.is_number()); + BEAST_EXPECT(! nul.is_number()); + } + // is_primitive() { BEAST_EXPECT(! obj.is_primitive()); @@ -1027,7 +1027,7 @@ public: BEAST_EXPECT( i64.is_primitive()); BEAST_EXPECT( u64.is_primitive()); BEAST_EXPECT( dub.is_primitive()); - BEAST_EXPECT( boo.is_primitive()); + BEAST_EXPECT( bln.is_primitive()); BEAST_EXPECT( nul.is_primitive()); } @@ -1039,13 +1039,19 @@ public: BEAST_EXPECT(! i64.is_structured()); BEAST_EXPECT(! u64.is_structured()); BEAST_EXPECT(! dub.is_structured()); - BEAST_EXPECT(! boo.is_structured()); + BEAST_EXPECT(! bln.is_structured()); BEAST_EXPECT(! nul.is_structured()); } } + //------------------------------------------------------ + // + // Accessors + // + //------------------------------------------------------ + void - testAccessors() + testGetStorage() { auto const sp = make_storage(); @@ -1056,18 +1062,9 @@ public: value i64(std::int64_t{}, sp); value u64(std::uint64_t{}, sp); value dub(double{}, sp); - value boo(true, sp); + value bln(true, sp); value nul(nullptr, sp); - auto const& cobj(obj); - auto const& carr(arr); - auto const& cstr(str); - auto const& ci64(i64); - auto const& cu64(u64); - auto const& cdub(dub); - auto const& cboo(boo); - auto const& cnul(nul); - // get_storage() { BEAST_EXPECT(*obj.get_storage() == *sp); @@ -1076,9 +1073,31 @@ public: BEAST_EXPECT(*i64.get_storage() == *sp); BEAST_EXPECT(*u64.get_storage() == *sp); BEAST_EXPECT(*dub.get_storage() == *sp); - BEAST_EXPECT(*boo.get_storage() == *sp); + BEAST_EXPECT(*bln.get_storage() == *sp); BEAST_EXPECT(*nul.get_storage() == *sp); } + } + + void + testIf() + { + value obj(object{}); + value arr(array{}); + value str(string{}); + value i64(std::int64_t{}); + value u64(std::uint64_t{}); + value dub(double{}); + value bln(true); + value nul(nullptr); + + auto const& cobj(obj); + auto const& carr(arr); + auto const& cstr(str); + auto const& ci64(i64); + auto const& cu64(u64); + auto const& cdub(dub); + auto const& cbln(bln); + auto const& cnul(nul); // if_object() { @@ -1088,7 +1107,7 @@ public: BEAST_EXPECT(i64.if_object() == nullptr); BEAST_EXPECT(u64.if_object() == nullptr); BEAST_EXPECT(dub.if_object() == nullptr); - BEAST_EXPECT(boo.if_object() == nullptr); + BEAST_EXPECT(bln.if_object() == nullptr); BEAST_EXPECT(nul.if_object() == nullptr); } @@ -1100,7 +1119,7 @@ public: BEAST_EXPECT(ci64.if_object() == nullptr); BEAST_EXPECT(cu64.if_object() == nullptr); BEAST_EXPECT(cdub.if_object() == nullptr); - BEAST_EXPECT(cboo.if_object() == nullptr); + BEAST_EXPECT(cbln.if_object() == nullptr); BEAST_EXPECT(cnul.if_object() == nullptr); } @@ -1112,7 +1131,7 @@ public: BEAST_EXPECT(i64.if_array() == nullptr); BEAST_EXPECT(u64.if_array() == nullptr); BEAST_EXPECT(dub.if_array() == nullptr); - BEAST_EXPECT(boo.if_array() == nullptr); + BEAST_EXPECT(bln.if_array() == nullptr); BEAST_EXPECT(nul.if_array() == nullptr); } @@ -1124,7 +1143,7 @@ public: BEAST_EXPECT(ci64.if_array() == nullptr); BEAST_EXPECT(cu64.if_array() == nullptr); BEAST_EXPECT(cdub.if_array() == nullptr); - BEAST_EXPECT(cboo.if_array() == nullptr); + BEAST_EXPECT(cbln.if_array() == nullptr); BEAST_EXPECT(cnul.if_array() == nullptr); } @@ -1136,7 +1155,7 @@ public: BEAST_EXPECT(i64.if_string() == nullptr); BEAST_EXPECT(u64.if_string() == nullptr); BEAST_EXPECT(dub.if_string() == nullptr); - BEAST_EXPECT(boo.if_string() == nullptr); + BEAST_EXPECT(bln.if_string() == nullptr); BEAST_EXPECT(nul.if_string() == nullptr); } @@ -1148,7 +1167,7 @@ public: BEAST_EXPECT(ci64.if_string() == nullptr); BEAST_EXPECT(cu64.if_string() == nullptr); BEAST_EXPECT(cdub.if_string() == nullptr); - BEAST_EXPECT(cboo.if_string() == nullptr); + BEAST_EXPECT(cbln.if_string() == nullptr); BEAST_EXPECT(cnul.if_string() == nullptr); } @@ -1160,7 +1179,7 @@ public: BEAST_EXPECT(i64.if_int64() != nullptr); BEAST_EXPECT(u64.if_int64() == nullptr); BEAST_EXPECT(dub.if_int64() == nullptr); - BEAST_EXPECT(boo.if_int64() == nullptr); + BEAST_EXPECT(bln.if_int64() == nullptr); BEAST_EXPECT(nul.if_int64() == nullptr); } @@ -1172,7 +1191,7 @@ public: BEAST_EXPECT(ci64.if_int64() != nullptr); BEAST_EXPECT(cu64.if_int64() == nullptr); BEAST_EXPECT(cdub.if_int64() == nullptr); - BEAST_EXPECT(cboo.if_int64() == nullptr); + BEAST_EXPECT(cbln.if_int64() == nullptr); BEAST_EXPECT(cnul.if_int64() == nullptr); } @@ -1184,7 +1203,7 @@ public: BEAST_EXPECT(i64.if_uint64() == nullptr); BEAST_EXPECT(u64.if_uint64() != nullptr); BEAST_EXPECT(dub.if_uint64() == nullptr); - BEAST_EXPECT(boo.if_uint64() == nullptr); + BEAST_EXPECT(bln.if_uint64() == nullptr); BEAST_EXPECT(nul.if_uint64() == nullptr); } @@ -1196,7 +1215,7 @@ public: BEAST_EXPECT(ci64.if_uint64() == nullptr); BEAST_EXPECT(cu64.if_uint64() != nullptr); BEAST_EXPECT(cdub.if_uint64() == nullptr); - BEAST_EXPECT(cboo.if_uint64() == nullptr); + BEAST_EXPECT(cbln.if_uint64() == nullptr); BEAST_EXPECT(cnul.if_uint64() == nullptr); } @@ -1208,7 +1227,7 @@ public: BEAST_EXPECT(i64.if_double() == nullptr); BEAST_EXPECT(u64.if_double() == nullptr); BEAST_EXPECT(dub.if_double() != nullptr); - BEAST_EXPECT(boo.if_double() == nullptr); + BEAST_EXPECT(bln.if_double() == nullptr); BEAST_EXPECT(nul.if_double() == nullptr); } @@ -1220,7 +1239,7 @@ public: BEAST_EXPECT(ci64.if_double() == nullptr); BEAST_EXPECT(cu64.if_double() == nullptr); BEAST_EXPECT(cdub.if_double() != nullptr); - BEAST_EXPECT(cboo.if_double() == nullptr); + BEAST_EXPECT(cbln.if_double() == nullptr); BEAST_EXPECT(cnul.if_double() == nullptr); } @@ -1232,7 +1251,7 @@ public: BEAST_EXPECT(i64.if_bool() == nullptr); BEAST_EXPECT(u64.if_bool() == nullptr); BEAST_EXPECT(dub.if_bool() == nullptr); - BEAST_EXPECT(boo.if_bool() != nullptr); + BEAST_EXPECT(bln.if_bool() != nullptr); BEAST_EXPECT(nul.if_bool() == nullptr); } @@ -1244,80 +1263,108 @@ public: BEAST_EXPECT(ci64.if_bool() == nullptr); BEAST_EXPECT(cu64.if_bool() == nullptr); BEAST_EXPECT(cdub.if_bool() == nullptr); - BEAST_EXPECT(cboo.if_bool() != nullptr); + BEAST_EXPECT(cbln.if_bool() != nullptr); BEAST_EXPECT(cnul.if_bool() == nullptr); } + } + + void + testAs() + { + value obj(object{}); + value arr(array{}); + value str(string{}); + value i64(std::int64_t{}); + value u64(std::uint64_t{}); + value dub(double{}); + value bln(true); + value nul(nullptr); + + auto const& cobj(obj); + auto const& carr(arr); + auto const& cstr(str); + auto const& ci64(i64); + auto const& cu64(u64); + auto const& cdub(dub); + auto const& cbln(bln); + auto const& cnul(nul); // as_object() { - obj.as_object(); + object& x = obj.as_object(); BEAST_THROWS(arr.as_object(), system_error); BEAST_THROWS(str.as_object(), system_error); BEAST_THROWS(i64.as_object(), system_error); BEAST_THROWS(u64.as_object(), system_error); BEAST_THROWS(dub.as_object(), system_error); - BEAST_THROWS(boo.as_object(), system_error); + BEAST_THROWS(bln.as_object(), system_error); BEAST_THROWS(nul.as_object(), system_error); + (void)x; } // as_object() const { - cobj.as_object(); + object const& x = cobj.as_object(); BEAST_THROWS(carr.as_object(), system_error); BEAST_THROWS(cstr.as_object(), system_error); BEAST_THROWS(ci64.as_object(), system_error); BEAST_THROWS(cu64.as_object(), system_error); BEAST_THROWS(cdub.as_object(), system_error); - BEAST_THROWS(cboo.as_object(), system_error); + BEAST_THROWS(cbln.as_object(), system_error); BEAST_THROWS(cnul.as_object(), system_error); + (void)x; } // as_array() { BEAST_THROWS(obj.as_array(), system_error); - arr.as_array(); + array& x = arr.as_array(); BEAST_THROWS(str.as_array(), system_error); BEAST_THROWS(i64.as_array(), system_error); BEAST_THROWS(u64.as_array(), system_error); BEAST_THROWS(dub.as_array(), system_error); - BEAST_THROWS(boo.as_array(), system_error); + BEAST_THROWS(bln.as_array(), system_error); BEAST_THROWS(nul.as_array(), system_error); + (void)x; } // as_array() const { BEAST_THROWS(cobj.as_array(), system_error); - carr.as_array(); + array const& x = carr.as_array(); BEAST_THROWS(cstr.as_array(), system_error); BEAST_THROWS(ci64.as_array(), system_error); BEAST_THROWS(cu64.as_array(), system_error); BEAST_THROWS(cdub.as_array(), system_error); - BEAST_THROWS(cboo.as_array(), system_error); + BEAST_THROWS(cbln.as_array(), system_error); BEAST_THROWS(cnul.as_array(), system_error); + (void)x; } // as_string() { BEAST_THROWS(obj.as_string(), system_error); BEAST_THROWS(arr.as_string(), system_error); - str.as_string(); + string& x = str.as_string(); BEAST_THROWS(i64.as_string(), system_error); BEAST_THROWS(u64.as_string(), system_error); BEAST_THROWS(dub.as_string(), system_error); - BEAST_THROWS(boo.as_string(), system_error); + BEAST_THROWS(bln.as_string(), system_error); BEAST_THROWS(nul.as_string(), system_error); + (void)x; } // as_string() const { BEAST_THROWS(cobj.as_string(), system_error); BEAST_THROWS(carr.as_string(), system_error); - cstr.as_string(); + string const& x = cstr.as_string(); BEAST_THROWS(ci64.as_string(), system_error); BEAST_THROWS(cu64.as_string(), system_error); BEAST_THROWS(cdub.as_string(), system_error); - BEAST_THROWS(cboo.as_string(), system_error); + BEAST_THROWS(cbln.as_string(), system_error); BEAST_THROWS(cnul.as_string(), system_error); + (void)x; } // as_int64() @@ -1325,11 +1372,12 @@ public: BEAST_THROWS(obj.as_int64(), system_error); BEAST_THROWS(arr.as_int64(), system_error); BEAST_THROWS(str.as_int64(), system_error); - i64.as_int64(); + std::int64_t& x = i64.as_int64(); BEAST_THROWS(u64.as_int64(), system_error); BEAST_THROWS(dub.as_int64(), system_error); - BEAST_THROWS(boo.as_int64(), system_error); + BEAST_THROWS(bln.as_int64(), system_error); BEAST_THROWS(nul.as_int64(), system_error); + (void)x; } // as_int64() const @@ -1337,11 +1385,12 @@ public: BEAST_THROWS(cobj.as_int64(), system_error); BEAST_THROWS(carr.as_int64(), system_error); BEAST_THROWS(cstr.as_int64(), system_error); - ci64.as_int64(); + std::int64_t const& x = ci64.as_int64(); BEAST_THROWS(cu64.as_int64(), system_error); BEAST_THROWS(cdub.as_int64(), system_error); - BEAST_THROWS(cboo.as_int64(), system_error); + BEAST_THROWS(cbln.as_int64(), system_error); BEAST_THROWS(cnul.as_int64(), system_error); + (void)x; } // as_uint64() @@ -1350,10 +1399,11 @@ public: BEAST_THROWS(arr.as_uint64(), system_error); BEAST_THROWS(str.as_uint64(), system_error); BEAST_THROWS(i64.as_uint64(), system_error); - u64.as_uint64(); + std::uint64_t& x = u64.as_uint64(); BEAST_THROWS(dub.as_uint64(), system_error); - BEAST_THROWS(boo.as_uint64(), system_error); + BEAST_THROWS(bln.as_uint64(), system_error); BEAST_THROWS(nul.as_uint64(), system_error); + (void)x; } // as_uint64() const @@ -1362,10 +1412,11 @@ public: BEAST_THROWS(carr.as_uint64(), system_error); BEAST_THROWS(cstr.as_uint64(), system_error); BEAST_THROWS(ci64.as_uint64(), system_error); - cu64.as_uint64(); +std::uint64_t const& x = cu64.as_uint64(); BEAST_THROWS(cdub.as_uint64(), system_error); - BEAST_THROWS(cboo.as_uint64(), system_error); + BEAST_THROWS(cbln.as_uint64(), system_error); BEAST_THROWS(cnul.as_uint64(), system_error); + (void)x; } // as_double() @@ -1375,9 +1426,10 @@ public: BEAST_THROWS(str.as_double(), system_error); BEAST_THROWS(i64.as_double(), system_error); BEAST_THROWS(u64.as_double(), system_error); - dub.as_double(); - BEAST_THROWS(boo.as_double(), system_error); + double& x = dub.as_double(); + BEAST_THROWS(bln.as_double(), system_error); BEAST_THROWS(nul.as_double(), system_error); + (void)x; } // as_uint64() const @@ -1387,9 +1439,10 @@ public: BEAST_THROWS(cstr.as_double(), system_error); BEAST_THROWS(ci64.as_double(), system_error); BEAST_THROWS(cu64.as_double(), system_error); - cdub.as_double(); - BEAST_THROWS(cboo.as_double(), system_error); + double const& x = cdub.as_double(); + BEAST_THROWS(cbln.as_double(), system_error); BEAST_THROWS(cnul.as_double(), system_error); + (void)x; } // as_bool() @@ -1400,8 +1453,9 @@ public: BEAST_THROWS(i64.as_bool(), system_error); BEAST_THROWS(u64.as_bool(), system_error); BEAST_THROWS(dub.as_bool(), system_error); - boo.as_bool(); + bool& x = bln.as_bool(); BEAST_THROWS(nul.as_bool(), system_error); + (void)x; } // as_bool() const @@ -1412,12 +1466,83 @@ public: BEAST_THROWS(ci64.as_bool(), system_error); BEAST_THROWS(cu64.as_bool(), system_error); BEAST_THROWS(cdub.as_bool(), system_error); - cboo.as_bool(); + bool const&x = cbln.as_bool(); BEAST_THROWS(cnul.as_bool(), system_error); + (void)x; } } - //------------------------------------------------------ + void + testGet() + { + value obj(object{}); + value arr(array{}); + value str(string{}); + value i64(std::int64_t{}); + value u64(std::uint64_t{}); + value dub(double{}); + value bln(true); + + auto const& cobj(obj); + auto const& carr(arr); + auto const& cstr(str); + auto const& ci64(i64); + auto const& cu64(u64); + auto const& cdub(dub); + auto const& cbln(bln); + + // get_object() + // get_array() + // get_string() + // get_int64() + // get_uint64() + // get_double() + // get_bool() + { + object& xobj = obj.get_object(); + array& xarr = arr.get_array(); + string& xstr = str.get_string(); + std::int64_t& xi64 = i64.get_int64(); + std::uint64_t& xu64 = u64.get_uint64(); + double& xdub = dub.get_double(); + bool& xbln = bln.get_bool(); + + (void)(xobj); + (void)(xarr); + (void)(xstr); + (void)(xi64); + (void)(xu64); + (void)(xdub); + (void)(xbln); + } + + // get_object() const + // get_array() const + // get_string() const + // get_int64() const + // get_uint64() const + // get_double() const + // get_bool() const + { + object const& xobj = cobj.get_object(); + array const& xarr = carr.get_array(); + string const& xstr = cstr.get_string(); + std::int64_t + const& xi64 = ci64.get_int64(); + std::uint64_t + const& xu64 = cu64.get_uint64(); + double const& xdub = cdub.get_double(); + bool const& xbln = cbln.get_bool(); + + (void)(xobj); + (void)(xarr); + (void)(xstr); + (void)(xi64); + (void)(xu64); + (void)(xdub); + (void)(xbln); + } + } void testCustomTypes() @@ -1455,7 +1580,10 @@ public: testModifiers(); testExchange(); testObservers(); - testAccessors(); + testGetStorage(); + testIf(); + testAs(); + testGet(); testCustomTypes(); } };