array.hpp 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_ARRAY_HPP
  10. #define BOOST_JSON_ARRAY_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/kind.hpp>
  13. #include <boost/json/pilfer.hpp>
  14. #include <boost/json/storage_ptr.hpp>
  15. #include <boost/json/detail/array.hpp>
  16. #include <cstdlib>
  17. #include <initializer_list>
  18. #include <iterator>
  19. BOOST_JSON_NS_BEGIN
  20. #ifndef BOOST_JSON_DOCS
  21. class value;
  22. class value_ref;
  23. #endif
  24. /** A dynamically sized array of JSON values
  25. This is the type used to represent a JSON array as
  26. a modifiable container. The interface and performance
  27. characteristics are modeled after `std::vector<value>`.
  28. \n
  29. Elements are stored contiguously, which means that
  30. they can be accessed not only through iterators, but
  31. also using offsets to regular pointers to elements. A
  32. pointer to an element of an @ref array may be passed to
  33. any function that expects a pointer to @ref value.
  34. \n
  35. The storage of the array is handled automatically, being
  36. expanded and contracted as needed. Arrays usually occupy
  37. more space than array language constructs, because more
  38. memory is allocated to handle future growth. This way an
  39. array does not need to reallocate each time an element
  40. is inserted, but only when the additional memory is used
  41. up. The total amount of allocated memory can be queried
  42. using the @ref capacity function. Extra memory can be
  43. relinquished by calling @ref shrink_to_fit.
  44. \n
  45. Reallocations are usually costly operations in terms of
  46. performance. The @ref reserve function can be used to
  47. eliminate reallocations if the number of elements is
  48. known beforehand.
  49. \n
  50. The complexity (efficiency) of common operations on
  51. arrays is as follows:
  52. @li Random access - constant *O(1)*.
  53. @li Insertion or removal of elements at the
  54. end - amortized constant *O(1)*.
  55. @li Insertion or removal of elements - linear in
  56. the distance to the end of the array *O(n)*.
  57. @par Allocators
  58. All elements stored in the container, and their
  59. children if any, will use the same memory resource
  60. that was used to construct the container.
  61. @par Thread Safety
  62. Non-const member functions may not be called
  63. concurrently with any other member functions.
  64. @par Satisfies
  65. <a href="https://en.cppreference.com/w/cpp/named_req/ContiguousContainer"><em>ContiguousContainer</em></a>,
  66. <a href="https://en.cppreference.com/w/cpp/named_req/ReversibleContainer"><em>ReversibleContainer</em></a>, and
  67. <a href="https://en.cppreference.com/w/cpp/named_req/SequenceContainer"><em>SequenceContainer</em></a>.
  68. */
  69. class array
  70. {
  71. struct table;
  72. class revert_construct;
  73. class revert_insert;
  74. friend class value;
  75. storage_ptr sp_; // must come first
  76. kind k_ = kind::array; // must come second
  77. table* t_;
  78. BOOST_JSON_DECL
  79. static table empty_;
  80. inline
  81. static
  82. void
  83. relocate(
  84. value* dest,
  85. value* src,
  86. std::size_t n) noexcept;
  87. inline
  88. void
  89. destroy(
  90. value* first,
  91. value* last) noexcept;
  92. BOOST_JSON_DECL
  93. void
  94. destroy() noexcept;
  95. BOOST_JSON_DECL
  96. explicit
  97. array(detail::unchecked_array&& ua);
  98. public:
  99. /** The type of <em>Allocator</em> returned by @ref get_allocator
  100. This type is a @ref polymorphic_allocator.
  101. */
  102. #ifdef BOOST_JSON_DOCS
  103. // VFALCO doc toolchain renders this incorrectly
  104. using allocator_type = __see_below__;
  105. #else
  106. using allocator_type = polymorphic_allocator<value>;
  107. #endif
  108. /// The type used to represent unsigned integers
  109. using size_type = std::size_t;
  110. /// The type of each element
  111. using value_type = value;
  112. /// The type used to represent signed integers
  113. using difference_type = std::ptrdiff_t;
  114. /// A reference to an element
  115. using reference = value&;
  116. /// A const reference to an element
  117. using const_reference = value const&;
  118. /// A pointer to an element
  119. using pointer = value*;
  120. /// A const pointer to an element
  121. using const_pointer = value const*;
  122. /// A random access iterator to an element
  123. using iterator = value*;
  124. /// A random access const iterator to an element
  125. using const_iterator = value const*;
  126. /// A reverse random access iterator to an element
  127. using reverse_iterator =
  128. std::reverse_iterator<iterator>;
  129. /// A reverse random access const iterator to an element
  130. using const_reverse_iterator =
  131. std::reverse_iterator<const_iterator>;
  132. //------------------------------------------------------
  133. /** Destructor.
  134. The destructor for each element is called if needed,
  135. any used memory is deallocated, and shared ownership
  136. of the @ref memory_resource is released.
  137. @par Complexity
  138. Constant, or linear in @ref size().
  139. @par Exception Safety
  140. No-throw guarantee.
  141. */
  142. BOOST_JSON_DECL
  143. ~array();
  144. //------------------------------------------------------
  145. /** Constructor.
  146. The constructed array is empty with zero
  147. capacity, using the default memory resource.
  148. @par Complexity
  149. Constant.
  150. @par Exception Safety
  151. No-throw guarantee.
  152. */
  153. array() noexcept
  154. : t_(&empty_)
  155. {
  156. }
  157. /** Constructor.
  158. The constructed array is empty with zero
  159. capacity, using the specified memory resource.
  160. @par Complexity
  161. Constant.
  162. @par Exception Safety
  163. No-throw guarantee.
  164. @param sp A pointer to the @ref memory_resource
  165. to use. The container will acquire shared
  166. ownership of the memory resource.
  167. */
  168. explicit
  169. array(storage_ptr sp) noexcept
  170. : sp_(std::move(sp))
  171. , k_(kind::array)
  172. , t_(&empty_)
  173. {
  174. }
  175. /** Constructor.
  176. The array is constructed with `count`
  177. copies of the value `v`, using the
  178. specified memory resource.
  179. @par Complexity
  180. Linear in `count`
  181. @par Exception Safety
  182. Strong guarantee.
  183. Calls to `memory_resource::allocate` may throw.
  184. @param count The number of copies to insert.
  185. @param v The value to be inserted.
  186. @param sp A pointer to the @ref memory_resource
  187. to use. The container will acquire shared
  188. ownership of the memory resource.
  189. */
  190. BOOST_JSON_DECL
  191. array(
  192. std::size_t count,
  193. value const& v,
  194. storage_ptr sp = {});
  195. /** Constructor.
  196. The array is constructed with `count` null values,
  197. using the specified memory resource.
  198. @par Complexity
  199. Linear in `count`
  200. @par Exception Safety
  201. Strong guarantee.
  202. Calls to `memory_resource::allocate` may throw.
  203. @param count The number of nulls to insert.
  204. @param sp A pointer to the @ref memory_resource
  205. to use. The container will acquire shared
  206. ownership of the memory resource.
  207. */
  208. BOOST_JSON_DECL
  209. array(
  210. std::size_t count,
  211. storage_ptr sp = {});
  212. /** Constructor.
  213. The array is constructed with the elements
  214. in the range `{first, last)`, preserving order,
  215. using the specified memory resource.
  216. @par Constraints
  217. @code
  218. std::is_constructible_v<value, std::iterator_traits<InputIt>::value_type>
  219. @endcode
  220. @par Complexity
  221. Linear in `std::distance(first, last)`
  222. @par Exception Safety
  223. Strong guarantee.
  224. Calls to `memory_resource::allocate` may throw.
  225. @param first An input iterator pointing to the
  226. first element to insert, or pointing to the end
  227. of the range.
  228. @param last An input iterator pointing to the end
  229. of the range.
  230. @param sp A pointer to the @ref memory_resource
  231. to use. The container will acquire shared
  232. ownership of the memory resource.
  233. @tparam InputIt a type satisfying the requirements
  234. of __InputIterator__.
  235. */
  236. template<
  237. class InputIt
  238. #ifndef BOOST_JSON_DOCS
  239. ,class = typename std::enable_if<
  240. std::is_constructible<value,
  241. typename std::iterator_traits<
  242. InputIt>::value_type>::value>::type
  243. #endif
  244. >
  245. array(
  246. InputIt first, InputIt last,
  247. storage_ptr sp = {});
  248. /** Copy constructor.
  249. The array is constructed with a copy of the
  250. contents of `other`, using `other`'s memory resource.
  251. @par Complexity
  252. Linear in `other.size()`.
  253. @par Exception Safety
  254. Strong guarantee.
  255. Calls to `memory_resource::allocate` may throw.
  256. @param other The array to copy
  257. */
  258. BOOST_JSON_DECL
  259. array(array const& other);
  260. /** Copy constructor.
  261. The array is constructed with a copy of the
  262. contents of `other`, using the specified memory resource.
  263. @par Complexity
  264. Linear in `other.size()`.
  265. @par Exception Safety
  266. Strong guarantee.
  267. Calls to `memory_resource::allocate` may throw.
  268. @param other The array to copy
  269. @param sp A pointer to the @ref memory_resource
  270. to use. The container will acquire shared
  271. ownership of the memory resource.
  272. */
  273. BOOST_JSON_DECL
  274. array(
  275. array const& other,
  276. storage_ptr sp);
  277. /** Pilfer constructor.
  278. The array is constructed by acquiring ownership
  279. of the contents of `other` using pilfer semantics.
  280. This is more efficient than move construction, when
  281. it is known that the moved-from object will be
  282. immediately destroyed afterwards.
  283. @par Complexity
  284. Constant.
  285. @par Exception Safety
  286. No-throw guarantee.
  287. @param other The value to pilfer. After pilfer
  288. construction, `other` is not in a usable state
  289. and may only be destroyed.
  290. @see @ref pilfer,
  291. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html">
  292. Valueless Variants Considered Harmful</a>
  293. */
  294. array(pilfered<array> other) noexcept
  295. : sp_(std::move(other.get().sp_))
  296. , t_(detail::exchange(
  297. other.get().t_, &empty_))
  298. {
  299. }
  300. /** Move constructor.
  301. The array is constructed by acquiring ownership of
  302. the contents of `other` and shared ownership of
  303. `other`'s memory resource.
  304. @note
  305. After construction, the moved-from array behaves
  306. as if newly constructed with its current storage
  307. pointer.
  308. @par Complexity
  309. Constant.
  310. @par Exception Safety
  311. No-throw guarantee.
  312. @param other The container to move
  313. */
  314. array(array&& other) noexcept
  315. : sp_(other.sp_)
  316. , t_(detail::exchange(
  317. other.t_, &empty_))
  318. {
  319. }
  320. /** Move constructor.
  321. The array is constructed with the contents of
  322. `other` by move semantics, using the specified
  323. memory resource:
  324. @li If `*other.storage() == *sp`, ownership of
  325. the underlying memory is transferred in constant
  326. time, with no possibility of exceptions.
  327. After construction, the moved-from array behaves
  328. as if newly constructed with its current storage
  329. pointer.
  330. @li If `*other.storage() != *sp`, an
  331. element-wise copy is performed, which may throw.
  332. In this case, the moved-from array is not
  333. changed.
  334. @par Complexity
  335. At most, linear in `other.size()`.
  336. @par Exception Safety
  337. Strong guarantee.
  338. Calls to `memory_resource::allocate` may throw.
  339. @param other The container to move
  340. @param sp A pointer to the @ref memory_resource
  341. to use. The container will acquire shared
  342. ownership of the memory resource.
  343. */
  344. BOOST_JSON_DECL
  345. array(
  346. array&& other,
  347. storage_ptr sp);
  348. /** Constructor.
  349. The array is constructed with a copy of the values
  350. in the initializer-list in order, using the
  351. specified memory resource.
  352. @par Complexity
  353. Linear in `init.size()`.
  354. @par Exception Safety
  355. Strong guarantee.
  356. Calls to `memory_resource::allocate` may throw.
  357. @param init The initializer list to insert
  358. @param sp A pointer to the @ref memory_resource
  359. to use. The container will acquire shared
  360. ownership of the memory resource.
  361. */
  362. BOOST_JSON_DECL
  363. array(
  364. std::initializer_list<value_ref> init,
  365. storage_ptr sp = {});
  366. //------------------------------------------------------
  367. /** Copy assignment.
  368. The contents of the array are replaced with an
  369. element-wise copy of `other`.
  370. @par Complexity
  371. Linear in @ref size() plus `other.size()`.
  372. @par Exception Safety
  373. Strong guarantee.
  374. Calls to `memory_resource::allocate` may throw.
  375. @param other The array to copy.
  376. */
  377. BOOST_JSON_DECL
  378. array&
  379. operator=(array const& other);
  380. /** Move assignment.
  381. The contents of the array are replaced with the
  382. contents of `other` using move semantics:
  383. @li If `*other.storage() == *sp`, ownership of
  384. the underlying memory is transferred in constant
  385. time, with no possibility of exceptions.
  386. After assignment, the moved-from array behaves
  387. as if newly constructed with its current storage
  388. pointer.
  389. @li If `*other.storage() != *sp`, an
  390. element-wise copy is performed, which may throw.
  391. In this case, the moved-from array is not
  392. changed.
  393. @par Complexity
  394. Constant, or linear in
  395. `this->size()` plus `other.size()`.
  396. @par Exception Safety
  397. Strong guarantee.
  398. Calls to `memory_resource::allocate` may throw.
  399. @param other The array to move.
  400. */
  401. BOOST_JSON_DECL
  402. array&
  403. operator=(array&& other);
  404. /** Assignment.
  405. The contents of the array are replaced with a
  406. copy of the values in the initializer-list.
  407. @par Complexity
  408. Linear in `this->size()` plus `init.size()`.
  409. @par Exception Safety
  410. Strong guarantee.
  411. Calls to `memory_resource::allocate` may throw.
  412. @param init The initializer list to copy.
  413. */
  414. BOOST_JSON_DECL
  415. array&
  416. operator=(
  417. std::initializer_list<value_ref> init);
  418. //------------------------------------------------------
  419. /** Return the associated @ref memory_resource
  420. This returns the @ref memory_resource used by
  421. the container.
  422. @par Complexity
  423. Constant.
  424. @par Exception Safety
  425. No-throw guarantee.
  426. */
  427. storage_ptr const&
  428. storage() const noexcept
  429. {
  430. return sp_;
  431. }
  432. /** Return the associated @ref memory_resource
  433. This function returns an instance of
  434. @ref polymorphic_allocator constructed from the
  435. associated @ref memory_resource.
  436. @par Complexity
  437. Constant.
  438. @par Exception Safety
  439. No-throw guarantee.
  440. */
  441. allocator_type
  442. get_allocator() const noexcept
  443. {
  444. return sp_.get();
  445. }
  446. //------------------------------------------------------
  447. //
  448. // Element access
  449. //
  450. //------------------------------------------------------
  451. /** Access an element, with bounds checking.
  452. Returns a reference to the element specified at
  453. location `pos`, with bounds checking. If `pos` is
  454. not within the range of the container, an exception
  455. of type `std::out_of_range` is thrown.
  456. @par Complexity
  457. Constant.
  458. @param pos A zero-based index.
  459. @throw std::out_of_range `pos >= size()`
  460. */
  461. inline
  462. value&
  463. at(std::size_t pos);
  464. /** Access an element, with bounds checking.
  465. Returns a reference to the element specified at
  466. location `pos`, with bounds checking. If `pos` is
  467. not within the range of the container, an exception
  468. of type `std::out_of_range` is thrown.
  469. @par Complexity
  470. Constant.
  471. @param pos A zero-based index.
  472. @throw std::out_of_range `pos >= size()`
  473. */
  474. inline
  475. value const&
  476. at(std::size_t pos) const;
  477. /** Access an element.
  478. Returns a reference to the element specified at
  479. location `pos`. No bounds checking is performed.
  480. @par Precondition
  481. `pos < size()`
  482. @par Complexity
  483. Constant.
  484. @param pos A zero-based index
  485. */
  486. inline
  487. value&
  488. operator[](std::size_t pos) noexcept;
  489. /** Access an element.
  490. Returns a reference to the element specified at
  491. location `pos`. No bounds checking is performed.
  492. @par Precondition
  493. `pos < size()`
  494. @par Complexity
  495. Constant.
  496. @param pos A zero-based index
  497. */
  498. inline
  499. value const&
  500. operator[](std::size_t pos) const noexcept;
  501. /** Access the first element.
  502. Returns a reference to the first element.
  503. @par Precondition
  504. `not empty()`
  505. @par Complexity
  506. Constant.
  507. */
  508. inline
  509. value&
  510. front() noexcept;
  511. /** Access the first element.
  512. Returns a reference to the first element.
  513. @par Precondition
  514. `not empty()`
  515. @par Complexity
  516. Constant.
  517. */
  518. inline
  519. value const&
  520. front() const noexcept;
  521. /** Access the last element.
  522. Returns a reference to the last element.
  523. @par Precondition
  524. `not empty()`
  525. @par Complexity
  526. Constant.
  527. */
  528. inline
  529. value&
  530. back() noexcept;
  531. /** Access the last element.
  532. Returns a reference to the last element.
  533. @par Precondition
  534. `not empty()`
  535. @par Complexity
  536. Constant.
  537. */
  538. inline
  539. value const&
  540. back() const noexcept;
  541. /** Access the underlying array directly.
  542. Returns a pointer to the underlying array serving
  543. as element storage. The value returned is such that
  544. the range `{data(), data() + size())` is always a
  545. valid range, even if the container is empty.
  546. @par Complexity
  547. Constant.
  548. @par Exception Safety
  549. No-throw guarantee.
  550. @note
  551. If `size() == 0`, the function may or may not return
  552. a null pointer.
  553. */
  554. inline
  555. value*
  556. data() noexcept;
  557. /** Access the underlying array directly.
  558. Returns a pointer to the underlying array serving
  559. as element storage. The value returned is such that
  560. the range `{data(), data() + size())` is always a
  561. valid range, even if the container is empty.
  562. @par Complexity
  563. Constant.
  564. @par Exception Safety
  565. No-throw guarantee.
  566. @note
  567. If `size() == 0`, the function may or may not return
  568. a null pointer.
  569. */
  570. inline
  571. value const*
  572. data() const noexcept;
  573. /** Return a pointer to an element, or nullptr if the index is invalid
  574. This function returns a pointer to the element
  575. at index `pos` when the index is less then the size
  576. of the container. Otherwise it returns null.
  577. @par Example
  578. @code
  579. if( auto p = arr.if_contains( 1 ) )
  580. std::cout << *p;
  581. @endcode
  582. @par Complexity
  583. Constant.
  584. @par Exception Safety
  585. No-throw guarantee.
  586. @param pos The index of the element to return.
  587. */
  588. inline
  589. value const*
  590. if_contains(std::size_t pos) const noexcept;
  591. /** Return a pointer to an element, or nullptr if the index is invalid
  592. This function returns a pointer to the element
  593. at index `pos` when the index is less then the size
  594. of the container. Otherwise it returns null.
  595. @par Example
  596. @code
  597. if( auto p = arr.if_contains( 1 ) )
  598. std::cout << *p;
  599. @endcode
  600. @par Complexity
  601. Constant.
  602. @par Exception Safety
  603. No-throw guarantee.
  604. @param pos The index of the element to return.
  605. */
  606. inline
  607. value*
  608. if_contains(std::size_t pos) noexcept;
  609. //------------------------------------------------------
  610. //
  611. // Iterators
  612. //
  613. //------------------------------------------------------
  614. /** Return an iterator to the first element.
  615. If the container is empty, @ref end() is returned.
  616. @par Complexity
  617. Constant.
  618. @par Exception Safety
  619. No-throw guarantee.
  620. */
  621. inline
  622. iterator
  623. begin() noexcept;
  624. /** Return a const iterator to the first element.
  625. If the container is empty, @ref end() is returned.
  626. @par Complexity
  627. Constant.
  628. @par Exception Safety
  629. No-throw guarantee.
  630. */
  631. inline
  632. const_iterator
  633. begin() const noexcept;
  634. /** Return a const iterator to the first element.
  635. If the container is empty, @ref cend() is returned.
  636. @par Complexity
  637. Constant.
  638. @par Exception Safety
  639. No-throw guarantee.
  640. */
  641. inline
  642. const_iterator
  643. cbegin() const noexcept;
  644. /** Return an iterator to the element following the last element.
  645. The element acts as a placeholder; attempting
  646. to access it results in undefined behavior.
  647. @par Complexity
  648. Constant.
  649. @par Exception Safety
  650. No-throw guarantee.
  651. */
  652. inline
  653. iterator
  654. end() noexcept;
  655. /** Return a const iterator to the element following the last element.
  656. The element acts as a placeholder; attempting
  657. to access it results in undefined behavior.
  658. @par Complexity
  659. Constant.
  660. @par Exception Safety
  661. No-throw guarantee.
  662. */
  663. inline
  664. const_iterator
  665. end() const noexcept;
  666. /** Return a const iterator to the element following the last element.
  667. The element acts as a placeholder; attempting
  668. to access it results in undefined behavior.
  669. @par Complexity
  670. Constant.
  671. @par Exception Safety
  672. No-throw guarantee.
  673. */
  674. inline
  675. const_iterator
  676. cend() const noexcept;
  677. /** Return a reverse iterator to the first element of the reversed container.
  678. The pointed-to element corresponds to the
  679. last element of the non-reversed container.
  680. If the container is empty, @ref rend() is returned.
  681. @par Complexity
  682. Constant.
  683. @par Exception Safety
  684. No-throw guarantee.
  685. */
  686. inline
  687. reverse_iterator
  688. rbegin() noexcept;
  689. /** Return a const reverse iterator to the first element of the reversed container.
  690. The pointed-to element corresponds to the
  691. last element of the non-reversed container.
  692. If the container is empty, @ref rend() is returned.
  693. @par Complexity
  694. Constant.
  695. @par Exception Safety
  696. No-throw guarantee.
  697. */
  698. inline
  699. const_reverse_iterator
  700. rbegin() const noexcept;
  701. /** Return a const reverse iterator to the first element of the reversed container.
  702. The pointed-to element corresponds to the
  703. last element of the non-reversed container.
  704. If the container is empty, @ref crend() is returned.
  705. @par Complexity
  706. Constant.
  707. @par Exception Safety
  708. No-throw guarantee.
  709. */
  710. inline
  711. const_reverse_iterator
  712. crbegin() const noexcept;
  713. /** Return a reverse iterator to the element following the last element of the reversed container.
  714. The pointed-to element corresponds to the element
  715. preceding the first element of the non-reversed container.
  716. The element acts as a placeholder; attempting
  717. to access it results in undefined behavior.
  718. @par Complexity
  719. Constant.
  720. @par Exception Safety
  721. No-throw guarantee.
  722. */
  723. inline
  724. reverse_iterator
  725. rend() noexcept;
  726. /** Return a const reverse iterator to the element following the last element of the reversed container.
  727. The pointed-to element corresponds to the element
  728. preceding the first element of the non-reversed container.
  729. The element acts as a placeholder; attempting
  730. to access it results in undefined behavior.
  731. @par Complexity
  732. Constant.
  733. @par Exception Safety
  734. No-throw guarantee.
  735. */
  736. inline
  737. const_reverse_iterator
  738. rend() const noexcept;
  739. /** Return a const reverse iterator to the element following the last element of the reversed container.
  740. The pointed-to element corresponds to the element
  741. preceding the first element of the non-reversed container.
  742. The element acts as a placeholder; attempting
  743. to access it results in undefined behavior.
  744. @par Complexity
  745. Constant.
  746. @par Exception Safety
  747. No-throw guarantee.
  748. */
  749. inline
  750. const_reverse_iterator
  751. crend() const noexcept;
  752. //------------------------------------------------------
  753. //
  754. // Capacity
  755. //
  756. //------------------------------------------------------
  757. /** Return the number of elements in the array.
  758. This returns the number of elements in the array.
  759. The value returned may be different from the number
  760. returned from @ref capacity.
  761. @par Complexity
  762. Constant.
  763. @par Exception Safety
  764. No-throw guarantee.
  765. */
  766. inline
  767. std::size_t
  768. size() const noexcept;
  769. /** Return the maximum number of elements any array can hold.
  770. The maximum is an implementation-defined number.
  771. This value is a theoretical limit; at runtime,
  772. the actual maximum size may be less due to
  773. resource limits.
  774. @par Complexity
  775. Constant.
  776. @par Exception Safety
  777. No-throw guarantee.
  778. */
  779. static
  780. inline
  781. constexpr
  782. std::size_t
  783. max_size() noexcept;
  784. /** Return the number of elements that can be held in currently allocated memory.
  785. This number may be larger than the value returned
  786. by @ref size().
  787. @par Complexity
  788. Constant.
  789. @par Exception Safety
  790. No-throw guarantee.
  791. */
  792. inline
  793. std::size_t
  794. capacity() const noexcept;
  795. /** Check if the array has no elements.
  796. Returns `true` if there are no elements in the
  797. array, i.e. @ref size() returns 0.
  798. @par Complexity
  799. Constant.
  800. @par Exception Safety
  801. No-throw guarantee.
  802. */
  803. inline
  804. bool
  805. empty() const noexcept;
  806. /** Increase the capacity to at least a certain amount.
  807. This increases the @ref capacity() to a value
  808. that is greater than or equal to `new_capacity`.
  809. If `new_capacity > capacity()`, new memory is
  810. allocated. Otherwise, the call has no effect.
  811. The number of elements and therefore the
  812. @ref size() of the container is not changed.
  813. \n
  814. If new memory is allocated, all iterators
  815. including any past-the-end iterators, and all
  816. references to the elements are invalidated.
  817. Otherwise, no iterators or references are
  818. invalidated.
  819. @par Complexity
  820. At most, linear in @ref size().
  821. @par Exception Safety
  822. Strong guarantee.
  823. Calls to `memory_resource::allocate` may throw.
  824. @param new_capacity The new capacity of the array.
  825. @throw std::length_error `new_capacity > max_size()`
  826. */
  827. inline
  828. void
  829. reserve(std::size_t new_capacity);
  830. /** Request the removal of unused capacity.
  831. This performs a non-binding request to reduce the
  832. capacity to the current size. The request may or
  833. may not be fulfilled. If reallocation occurs, all
  834. iterators including any past-the-end iterators,
  835. and all references to the elements are invalidated.
  836. Otherwise, no iterators or references are
  837. invalidated.
  838. @par Complexity
  839. At most, linear in @ref size().
  840. @par Exception Safety
  841. No-throw guarantee.
  842. */
  843. BOOST_JSON_DECL
  844. void
  845. shrink_to_fit() noexcept;
  846. //------------------------------------------------------
  847. //
  848. // Modifiers
  849. //
  850. //------------------------------------------------------
  851. /** Clear the contents.
  852. Erases all elements from the container. After this
  853. call, @ref size() returns zero but @ref capacity()
  854. is unchanged. All references, pointers, or iterators
  855. referring to contained elements are invalidated. Any
  856. past-the-end iterators are also invalidated.
  857. @par Complexity
  858. Linear in @ref size().
  859. @par Exception Safety
  860. No-throw guarantee.
  861. */
  862. BOOST_JSON_DECL
  863. void
  864. clear() noexcept;
  865. /** Insert elements before the specified location.
  866. This inserts a copy of `v` before `pos`.
  867. If `capacity() < size() + 1`, a reallocation
  868. occurs first, and all iterators and references
  869. are invalidated.
  870. Otherwise, only the iterators and references from
  871. the insertion point forward are invalidated. All
  872. past-the-end iterators are also invalidated.
  873. @par Complexity
  874. Constant plus linear in `std::distance(pos, end())`.
  875. @par Exception Safety
  876. Strong guarantee.
  877. Calls to `memory_resource::allocate` may throw.
  878. @param pos Iterator before which the content will
  879. be inserted. This may be the @ref end() iterator.
  880. @param v The value to insert. A copy will be made
  881. using container's associated @ref memory_resource.
  882. @return An iterator to the inserted value
  883. */
  884. BOOST_JSON_DECL
  885. iterator
  886. insert(
  887. const_iterator pos,
  888. value const& v);
  889. /** Insert elements before the specified location.
  890. This inserts `v` before `pos` via move-construction.
  891. If `capacity() < size() + 1`, a reallocation occurs
  892. first, and all iterators and references are
  893. invalidated.
  894. Otherwise, only the iterators and references from
  895. the insertion point forward are invalidated. All
  896. past-the-end iterators are also invalidated.
  897. @par Complexity
  898. Constant plus linear in `std::distance(pos, end())`.
  899. @par Exception Safety
  900. Strong guarantee.
  901. Calls to `memory_resource::allocate` may throw.
  902. @param pos Iterator before which the content will
  903. be inserted. This may be the @ref end() iterator.
  904. @param v The value to insert. Ownership of the
  905. value will be transferred via move construction,
  906. using the container's associated @ref memory_resource.
  907. @return An iterator to the inserted value
  908. */
  909. BOOST_JSON_DECL
  910. iterator
  911. insert(
  912. const_iterator pos,
  913. value&& v);
  914. /** Insert elements before the specified location.
  915. This inserts `count` copies of `v` before `pos`.
  916. If `capacity() < size() + count`, a reallocation
  917. occurs first, and all iterators and references are
  918. invalidated.
  919. Otherwise, only the iterators and references from
  920. the insertion point forward are invalidated. All
  921. past-the-end iterators are also invalidated.
  922. @par Complexity
  923. Linear in `count + std::distance(pos, end())`.
  924. @par Exception Safety
  925. Strong guarantee.
  926. Calls to `memory_resource::allocate` may throw.
  927. @param pos Iterator before which the content will
  928. be inserted. This may be the @ref end() iterator.
  929. @param count The number of copies to insert.
  930. @param v The value to insert. Copies will be made
  931. using container's associated @ref memory_resource.
  932. @return An iterator to the first inserted value,
  933. or `pos` if `count == 0`.
  934. */
  935. BOOST_JSON_DECL
  936. iterator
  937. insert(
  938. const_iterator pos,
  939. std::size_t count,
  940. value const& v);
  941. /** Insert elements before the specified location.
  942. The elements in the range `{first, last)` are
  943. inserted in order.
  944. If `capacity() < size() + std::distance(first, last)`,
  945. a reallocation occurs first, and all iterators and
  946. references are invalidated.
  947. Otherwise, only the iterators and references from
  948. the insertion point forward are invalidated. All
  949. past-the-end iterators are also invalidated.
  950. @par Precondition
  951. `first` and `last` are not iterators into `*this`.
  952. @par Constraints
  953. @code
  954. not std::is_convertible_v<InputIt, value>
  955. @endcode
  956. @par Mandates
  957. @code
  958. std::is_constructible_v<value, std::iterator_traits<InputIt>::value_type>
  959. @endcode
  960. @par Complexity
  961. Linear in `std::distance(first, last) + std::distance(pos, end())`.
  962. @par Exception Safety
  963. Strong guarantee.
  964. Calls to `memory_resource::allocate` may throw.
  965. @return An iterator to the first inserted value, or
  966. `pos` if `first == last`.
  967. @param pos Iterator before which the content will
  968. be inserted. This may be the @ref end() iterator.
  969. @param first An input iterator pointing to the first
  970. element to insert, or pointing to the end of the range.
  971. @param last An input iterator pointing to the end
  972. of the range.
  973. @tparam InputIt a type satisfying the requirements
  974. of __InputIterator__.
  975. */
  976. template<
  977. class InputIt
  978. #ifndef BOOST_JSON_DOCS
  979. ,class = typename std::enable_if<
  980. std::is_constructible<value,
  981. typename std::iterator_traits<
  982. InputIt>::value_type>::value>::type
  983. #endif
  984. >
  985. iterator
  986. insert(
  987. const_iterator pos,
  988. InputIt first, InputIt last);
  989. /** Insert elements before the specified location.
  990. The elements in the initializer list `init` are
  991. inserted in order.
  992. If `capacity() < size() + init.size()`,
  993. a reallocation occurs first, and all iterators and
  994. references are invalidated.
  995. Otherwise, only the iterators and references from
  996. the insertion point forward are invalidated. All
  997. past-the-end iterators are also invalidated.
  998. @par Complexity
  999. Linear in `init.size() + std::distance(pos, end())`.
  1000. @par Exception Safety
  1001. Strong guarantee.
  1002. Calls to `memory_resource::allocate` may throw.
  1003. @param pos Iterator before which the content will
  1004. be inserted. This may be the @ref end() iterator.
  1005. @param init The initializer list to insert
  1006. @return An iterator to the first inserted value, or
  1007. `pos` if `init.size() == 0`.
  1008. */
  1009. BOOST_JSON_DECL
  1010. iterator
  1011. insert(
  1012. const_iterator pos,
  1013. std::initializer_list<value_ref> init);
  1014. /** Insert a constructed element in-place.
  1015. Inserts a new element into the container directly before
  1016. `pos`. The element is constructed using placement-new
  1017. with the parameter `std::forward<Arg>(arg)`.
  1018. If `capacity() < size() + 1`,
  1019. a reallocation occurs first, and all iterators and
  1020. references are invalidated.
  1021. Otherwise, only the iterators and references from
  1022. the insertion point forward are invalidated. All
  1023. past-the-end iterators are also invalidated.
  1024. @par Complexity
  1025. Constant plus linear in `std::distance(pos, end())`.
  1026. @par Exception Safety
  1027. Strong guarantee.
  1028. Calls to `memory_resource::allocate` may throw.
  1029. @param pos Iterator before which the element will
  1030. be inserted. This may be the @ref end() iterator.
  1031. @param arg The argument to forward to the @ref value
  1032. constructor.
  1033. @return An iterator to the inserted element
  1034. */
  1035. template<class Arg>
  1036. iterator
  1037. emplace(
  1038. const_iterator pos,
  1039. Arg&& arg);
  1040. /** Erase elements from the container.
  1041. The element at `pos` is removed.
  1042. @par Complexity
  1043. Constant plus linear in `std::distance(pos, end())`
  1044. @par Exception Safety
  1045. No-throw guarantee.
  1046. @param pos Iterator to the element to remove
  1047. @return Iterator following the last removed element.
  1048. If the iterator `pos` refers to the last element,
  1049. the @ref end() iterator is returned.
  1050. */
  1051. BOOST_JSON_DECL
  1052. iterator
  1053. erase(const_iterator pos) noexcept;
  1054. /** Erase elements from the container.
  1055. The elements in the range `{first, last)` are removed.
  1056. @par Complexity
  1057. Linear in `std::distance(first, last) + std::distance(pos, end())`
  1058. @par Exception Safety
  1059. No-throw guarantee.
  1060. @param first An iterator pointing to the first
  1061. element to erase, or pointing to the end of the range.
  1062. @param last An iterator pointing to one past the
  1063. last element to erase, or pointing to the end of the
  1064. range.
  1065. @return Iterator following the last removed element.
  1066. If the iterator `pos` refers to the last element,
  1067. the @ref end() iterator is returned.
  1068. */
  1069. BOOST_JSON_DECL
  1070. iterator
  1071. erase(
  1072. const_iterator first,
  1073. const_iterator last) noexcept;
  1074. /** Add an element to the end.
  1075. This appends a copy of `v` to the container's
  1076. elements.
  1077. If `capacity() < size() + 1`, a reallocation
  1078. occurs first, and all iterators and references
  1079. are invalidated. Any past-the-end iterators are
  1080. always invalidated.
  1081. @par Complexity
  1082. Amortized constant.
  1083. @par Exception Safety
  1084. Strong guarantee.
  1085. Calls to `memory_resource::allocate` may throw.
  1086. @param v The value to insert. A copy will be made
  1087. using container's associated @ref memory_resource.
  1088. */
  1089. BOOST_JSON_DECL
  1090. void
  1091. push_back(value const& v);
  1092. /** Add an element to the end.
  1093. This appends `v` to the container's elements via
  1094. move-construction.
  1095. If `capacity() < size() + 1`, a reallocation
  1096. occurs first, and all iterators and references
  1097. are invalidated. Any past-the-end iterators are
  1098. always invalidated.
  1099. @par Complexity
  1100. Amortized constant.
  1101. @par Exception Safety
  1102. Strong guarantee.
  1103. Calls to `memory_resource::allocate` may throw.
  1104. @param v The value to insert. Ownership of the
  1105. value will be transferred via move construction,
  1106. using the container's associated @ref memory_resource.
  1107. */
  1108. BOOST_JSON_DECL
  1109. void
  1110. push_back(value&& v);
  1111. /** Append a constructed element in-place.
  1112. Appends a new element to the end of the container's
  1113. list of elements.
  1114. The element is constructed using placement-new
  1115. with the parameter `std::forward<Arg>(arg)`.
  1116. If `capacity() < size() + 1`,
  1117. a reallocation occurs first, and all iterators and
  1118. references are invalidated.
  1119. Otherwise, only the iterators and references from
  1120. the insertion point forward are invalidated. All
  1121. past-the-end iterators are also invalidated.
  1122. @par Complexity
  1123. Amortized constant.
  1124. @par Exception Safety
  1125. Strong guarantee.
  1126. Calls to `memory_resource::allocate` may throw.
  1127. @param arg The argument to forward to the @ref value
  1128. constructor.
  1129. @return A reference to the inserted element
  1130. */
  1131. template<class Arg>
  1132. value&
  1133. emplace_back(Arg&& arg);
  1134. /** Remove the last element
  1135. The last element of the container is erased.
  1136. @par Precondition
  1137. `not empty()`
  1138. @par Exception Safety
  1139. No-throw guarantee.
  1140. */
  1141. BOOST_JSON_DECL
  1142. void
  1143. pop_back() noexcept;
  1144. /** Change the number of elements stored.
  1145. Resizes the container to contain `count` elements.
  1146. If `capacity() < size() + count`, a reallocation
  1147. occurs first, and all iterators and references
  1148. are invalidated. Any past-the-end iterators are
  1149. always invalidated.
  1150. @li If `size() > count`, the container is reduced
  1151. to its first `count` elements.
  1152. @li If `size() < count`, additional null values
  1153. are appended.
  1154. @par Complexity
  1155. Linear in `abs(size() - count)`, plus the cost of
  1156. reallocation if @ref capacity() is less than `count`.
  1157. @par Exception Safety
  1158. Strong guarantee.
  1159. Calls to `memory_resource::allocate` may throw.
  1160. @param count The new size of the container.
  1161. */
  1162. BOOST_JSON_DECL
  1163. void
  1164. resize(std::size_t count);
  1165. /** Change the number of elements stored.
  1166. Resizes the container to contain `count` elements.
  1167. If `capacity() < size() + count`, a reallocation
  1168. occurs first, and all iterators and references
  1169. are invalidated. Any past-the-end iterators are
  1170. always invalidated.
  1171. @li If `size() > count`, the container is reduced
  1172. to its first `count` elements.
  1173. @li If `size() < count`, additional copies of `v`
  1174. are appended.
  1175. @par Complexity
  1176. Linear in `abs(size() - count)`, plus the cost of
  1177. reallocation if @ref capacity() is less than `count`.
  1178. @par Exception Safety
  1179. Strong guarantee.
  1180. Calls to `memory_resource::allocate` may throw.
  1181. @param count The new size of the container.
  1182. @param v The @ref value to copy into the new elements.
  1183. */
  1184. BOOST_JSON_DECL
  1185. void
  1186. resize(
  1187. std::size_t count,
  1188. value const& v);
  1189. /** Swap the contents.
  1190. Exchanges the contents of this array with another
  1191. array. Ownership of the respective @ref memory_resource
  1192. objects is not transferred.
  1193. @li If `*other.storage() == *this->storage()`,
  1194. ownership of the underlying memory is swapped in
  1195. constant time, with no possibility of exceptions.
  1196. All iterators and references remain valid.
  1197. @li If `*other.storage() != *this->storage()`,
  1198. the contents are logically swapped by making copies,
  1199. which can throw. In this case all iterators and
  1200. references are invalidated.
  1201. @par Complexity
  1202. Constant or linear in @ref size() plus `other.size()`.
  1203. @par Exception Safety
  1204. Strong guarantee.
  1205. Calls to `memory_resource::allocate` may throw.
  1206. @param other The value to swap with.
  1207. If `this == &other`, this function call has no effect.
  1208. */
  1209. BOOST_JSON_DECL
  1210. void
  1211. swap(array& other);
  1212. /** Exchange the given values.
  1213. Exchanges the contents of the array `lhs` with
  1214. another array `rhs`. Ownership of the respective
  1215. @ref memory_resource objects is not transferred.
  1216. @li If `*lhs.storage() == *rhs.storage()`,
  1217. ownership of the underlying memory is swapped in
  1218. constant time, with no possibility of exceptions.
  1219. All iterators and references remain valid.
  1220. @li If `*lhs.storage() != *rhs.storage()`,
  1221. the contents are logically swapped by making a copy,
  1222. which can throw. In this case all iterators and
  1223. references are invalidated.
  1224. @par Effects
  1225. @code
  1226. lhs.swap( rhs );
  1227. @endcode
  1228. @par Complexity
  1229. Constant or linear in `lhs.size() + rhs.size()`.
  1230. @par Exception Safety
  1231. Strong guarantee.
  1232. Calls to `memory_resource::allocate` may throw.
  1233. @param lhs The array to exchange.
  1234. @param rhs The array to exchange.
  1235. If `&lhs == &rhs`, this function call has no effect.
  1236. @see @ref array::swap
  1237. */
  1238. friend
  1239. void
  1240. swap(array& lhs, array& rhs)
  1241. {
  1242. lhs.swap(rhs);
  1243. }
  1244. /** Return `true` if two arrays are equal.
  1245. Arrays are equal when their sizes are
  1246. the same, and they are element-for-element
  1247. equal in order.
  1248. @par Effects
  1249. `return std::equal( lhs.begin(), lhs.end(), rhs.begin(), rhs.end() );`
  1250. @par Complexity
  1251. Constant or linear in `lhs.size()`.
  1252. @par Exception Safety
  1253. No-throw guarantee.
  1254. */
  1255. // inline friend speeds up overload resolution
  1256. friend
  1257. bool
  1258. operator==(
  1259. array const& lhs,
  1260. array const& rhs) noexcept
  1261. {
  1262. return lhs.equal(rhs);
  1263. }
  1264. /** Return `true` if two arrays are not equal.
  1265. Arrays are equal when their sizes are
  1266. the same, and they are element-for-element
  1267. equal in order.
  1268. @par Effects
  1269. `return ! std::equal( lhs.begin(), lhs.end(), rhs.begin(), rhs.end() );`
  1270. @par Complexity
  1271. Constant or linear in `lhs.size()`.
  1272. @par Exception Safety
  1273. No-throw guarantee.
  1274. */
  1275. // inline friend speeds up overload resolution
  1276. friend
  1277. bool
  1278. operator!=(
  1279. array const& lhs,
  1280. array const& rhs) noexcept
  1281. {
  1282. return ! (lhs == rhs);
  1283. }
  1284. private:
  1285. template<class It>
  1286. using iter_cat = typename
  1287. std::iterator_traits<It>::iterator_category;
  1288. template<class InputIt>
  1289. array(
  1290. InputIt first, InputIt last,
  1291. storage_ptr sp,
  1292. std::input_iterator_tag);
  1293. template<class InputIt>
  1294. array(
  1295. InputIt first, InputIt last,
  1296. storage_ptr sp,
  1297. std::forward_iterator_tag);
  1298. inline
  1299. std::size_t
  1300. growth(std::size_t new_size) const;
  1301. BOOST_JSON_DECL
  1302. void
  1303. reserve_impl(
  1304. std::size_t new_capacity);
  1305. BOOST_JSON_DECL
  1306. value&
  1307. push_back(
  1308. pilfered<value> pv);
  1309. BOOST_JSON_DECL
  1310. iterator
  1311. insert(
  1312. const_iterator pos,
  1313. pilfered<value> pv);
  1314. template<class InputIt>
  1315. iterator
  1316. insert(
  1317. const_iterator pos,
  1318. InputIt first, InputIt last,
  1319. std::input_iterator_tag);
  1320. template<class InputIt>
  1321. iterator
  1322. insert(
  1323. const_iterator pos,
  1324. InputIt first, InputIt last,
  1325. std::forward_iterator_tag);
  1326. BOOST_JSON_DECL
  1327. bool
  1328. equal(array const& other) const noexcept;
  1329. };
  1330. BOOST_JSON_NS_END
  1331. // Must be included here for this file to stand alone
  1332. #include <boost/json/value.hpp>
  1333. // includes are at the bottom of <boost/json/value.hpp>
  1334. #endif