File tree Expand file tree Collapse file tree 13 files changed +276
-159
lines changed Expand file tree Collapse file tree 13 files changed +276
-159
lines changed Original file line number Diff line number Diff line change @@ -616,20 +616,29 @@ class array
616616
617617 @param pos A zero-based index.
618618
619+ @param loc `source_location` to use in thrown exception; the source
620+ location of the call site by default.
621+
619622 @throw `boost::system::system_error` `pos >= size()`.
620623 */
621624 /* * @{ */
622625 inline
623626 value&
624- at (std::size_t pos) &;
627+ at (
628+ std::size_t pos,
629+ source_location const & loc = BOOST_CURRENT_LOCATION) &;
625630
626631 inline
627632 value&&
628- at (std::size_t pos) &&;
633+ at (
634+ std::size_t pos,
635+ source_location const & loc = BOOST_CURRENT_LOCATION) &&;
629636
630637 BOOST_JSON_DECL
631638 value const &
632- at (std::size_t pos) const &;
639+ at (
640+ std::size_t pos,
641+ source_location const & loc = BOOST_CURRENT_LOCATION) const &;
633642 /* * @} */
634643
635644 /* * Access an element.
Original file line number Diff line number Diff line change @@ -204,17 +204,17 @@ emplace_back(Arg&& arg)
204204
205205value&
206206array::
207- at (std::size_t pos) &
207+ at (std::size_t pos, source_location const & loc ) &
208208{
209209 auto const & self = *this ;
210- return const_cast < value& >( self.at (pos) );
210+ return const_cast < value& >( self.at (pos, loc ) );
211211}
212212
213213value&&
214214array::
215- at (std::size_t pos) &&
215+ at (std::size_t pos, source_location const & loc ) &&
216216{
217- return std::move ( at (pos) );
217+ return std::move ( at (pos, loc ) );
218218}
219219
220220value&
Original file line number Diff line number Diff line change @@ -400,9 +400,9 @@ array::try_at(std::size_t pos) const noexcept
400400
401401value const &
402402array::
403- array::at (std::size_t pos) const &
403+ array::at (std::size_t pos, source_location const & loc ) const &
404404{
405- return try_at (pos).value ();
405+ return try_at (pos).value (loc );
406406}
407407
408408// ----------------------------------------------------------
Original file line number Diff line number Diff line change @@ -362,17 +362,17 @@ reserve(std::size_t new_capacity)
362362
363363value&
364364object::
365- at (string_view key) &
365+ at (string_view key, source_location const & loc ) &
366366{
367367 auto const & self = *this ;
368- return const_cast < value& >( self.at (key) );
368+ return const_cast < value& >( self.at (key, loc ) );
369369}
370370
371371value&&
372372object::
373- at (string_view key) &&
373+ at (string_view key, source_location const & loc ) &&
374374{
375- return std::move ( at (key) );
375+ return std::move ( at (key, loc ) );
376376}
377377
378378// ----------------------------------------------------------
Original file line number Diff line number Diff line change @@ -455,9 +455,9 @@ try_at(string_view key) const noexcept
455455
456456value const &
457457object::
458- at (string_view key) const &
458+ at (string_view key, source_location const & loc ) const &
459459{
460- return try_at (key).value ();
460+ return try_at (key).value (loc );
461461}
462462
463463// ----------------------------------------------------------
Original file line number Diff line number Diff line change @@ -341,6 +341,12 @@ walk_pointer(
341341
342342} // namespace detail
343343
344+ value const &
345+ value::at_pointer (string_view ptr, source_location const & loc) const &
346+ {
347+ return try_at_pointer (ptr).value (loc);
348+ }
349+
344350system::result<value const &>
345351value::try_at_pointer (string_view ptr) const noexcept
346352{
Original file line number Diff line number Diff line change @@ -239,11 +239,11 @@ append(
239239}
240240
241241char &
242- string::at (std::size_t pos)
242+ string::at (std::size_t pos, source_location const & loc )
243243{
244244
245245 auto const & self = *this ;
246- return const_cast < char & >( self.at (pos) );
246+ return const_cast < char & >( self.at (pos, loc ) );
247247}
248248
249249} // namespace json
Original file line number Diff line number Diff line change @@ -233,9 +233,9 @@ string::try_at(std::size_t pos) const noexcept
233233}
234234
235235char const &
236- string::at (std::size_t pos) const
236+ string::at (std::size_t pos, source_location const & loc ) const
237237{
238- return try_at (pos).value ();
238+ return try_at (pos).value (loc );
239239}
240240
241241// ----------------------------------------------------------
Original file line number Diff line number Diff line change 1313namespace boost {
1414namespace json {
1515
16- value const &
17- value::at_pointer (string_view ptr) const &
18- {
19- return try_at_pointer (ptr).value ();
20- }
21-
2216value&
23- value::at_pointer (string_view ptr) &
17+ value::at_pointer (string_view ptr, source_location const & loc ) &
2418{
25- return try_at_pointer (ptr).value ();
19+ auto const & self = *this ;
20+ return const_cast <value&>( self.at_pointer (ptr, loc) );
2621}
2722
2823value&&
29- value::at_pointer (string_view ptr) &&
24+ value::at_pointer (string_view ptr, source_location const & loc ) &&
3025{
31- return std::move ( try_at_pointer (ptr). value ( ) );
26+ return std::move ( at_pointer (ptr, loc ) );
3227}
3328
3429} // namespace json
Original file line number Diff line number Diff line change @@ -563,6 +563,72 @@ value::try_at(std::size_t pos) const noexcept
563563 return r->try_at (pos);
564564}
565565
566+ object const &
567+ value::as_object (source_location const & loc) const &
568+ {
569+ return try_as_object ().value (loc);
570+ }
571+
572+ array const &
573+ value::as_array (source_location const & loc) const &
574+ {
575+ return try_as_array ().value (loc);
576+ }
577+
578+ string const &
579+ value::as_string (source_location const & loc) const &
580+ {
581+ return try_as_string ().value (loc);
582+ }
583+
584+ std::int64_t &
585+ value::as_int64 (source_location const & loc)
586+ {
587+ return try_as_int64 ().value (loc);
588+ }
589+
590+ std::int64_t
591+ value::as_int64 (source_location const & loc) const
592+ {
593+ return try_as_int64 ().value (loc);
594+ }
595+
596+ std::uint64_t &
597+ value::as_uint64 (source_location const & loc)
598+ {
599+ return try_as_uint64 ().value (loc);
600+ }
601+
602+ std::uint64_t
603+ value::as_uint64 (source_location const & loc) const
604+ {
605+ return try_as_uint64 ().value (loc);
606+ }
607+
608+ double &
609+ value::as_double (source_location const & loc)
610+ {
611+ return try_as_double ().value (loc);
612+ }
613+
614+ double
615+ value::as_double (source_location const & loc) const
616+ {
617+ return try_as_double ().value (loc);
618+ }
619+
620+ bool &
621+ value::as_bool (source_location const & loc)
622+ {
623+ return try_as_bool ().value (loc);
624+ }
625+
626+ bool
627+ value::as_bool (source_location const & loc) const
628+ {
629+ return try_as_bool ().value (loc);
630+ }
631+
566632// ----------------------------------------------------------
567633//
568634// Modifiers
You can’t perform that action at this time.
0 commit comments