@@ -53,13 +53,9 @@ class JsonReverseIterator;
53
53
* @author Timothy Flynn ([email protected] )
54
54
* @version May 17, 2020
55
55
*/
56
- template <typename JsonType>
56
+ template <fly::SameAs<Json> JsonType>
57
57
class JsonIterator
58
58
{
59
- static_assert (
60
- fly::SameAs<Json, JsonType>,
61
- " JsonIterator must only be declared for a Json type" );
62
-
63
59
static constexpr bool is_const_iterator = std::is_const_v<JsonType>;
64
60
65
61
/* *
@@ -487,7 +483,7 @@ class JsonIterator
487
483
};
488
484
489
485
// ==================================================================================================
490
- template <typename JsonType>
486
+ template <fly::SameAs<Json> JsonType>
491
487
JsonIterator<JsonType>::JsonIterator(pointer json, Position position) noexcept (false ) : m_json(json)
492
488
{
493
489
auto visitor = [this , &position](auto &value) noexcept (JsonIterable<decltype (value)>)
@@ -517,7 +513,7 @@ JsonIterator<JsonType>::JsonIterator(pointer json, Position position) noexcept(f
517
513
}
518
514
519
515
// ==================================================================================================
520
- template <typename JsonType>
516
+ template <fly::SameAs<Json> JsonType>
521
517
JsonIterator<JsonType>::JsonIterator(const NonConstJsonIterator &iterator) noexcept :
522
518
m_json (iterator.m_json)
523
519
{
@@ -530,7 +526,7 @@ JsonIterator<JsonType>::JsonIterator(const NonConstJsonIterator &iterator) noexc
530
526
}
531
527
532
528
// ==================================================================================================
533
- template <typename JsonType>
529
+ template <fly::SameAs<Json> JsonType>
534
530
JsonIterator<JsonType> &
535
531
JsonIterator<JsonType>::operator =(const NonConstJsonIterator &iterator) noexcept
536
532
{
@@ -546,7 +542,7 @@ JsonIterator<JsonType>::operator=(const NonConstJsonIterator &iterator) noexcept
546
542
}
547
543
548
544
// ==================================================================================================
549
- template <typename JsonType>
545
+ template <fly::SameAs<Json> JsonType>
550
546
auto JsonIterator<JsonType>::operator *() const -> reference
551
547
{
552
548
validate_iterator ();
@@ -569,7 +565,7 @@ auto JsonIterator<JsonType>::operator*() const -> reference
569
565
}
570
566
571
567
// ==================================================================================================
572
- template <typename JsonType>
568
+ template <fly::SameAs<Json> JsonType>
573
569
auto JsonIterator<JsonType>::operator ->() const -> pointer
574
570
{
575
571
validate_iterator ();
@@ -592,7 +588,7 @@ auto JsonIterator<JsonType>::operator->() const -> pointer
592
588
}
593
589
594
590
// ==================================================================================================
595
- template <typename JsonType>
591
+ template <fly::SameAs<Json> JsonType>
596
592
auto JsonIterator<JsonType>::operator [](difference_type offset) const -> reference
597
593
{
598
594
validate_iterator ();
@@ -618,22 +614,22 @@ auto JsonIterator<JsonType>::operator[](difference_type offset) const -> referen
618
614
}
619
615
620
616
// ==================================================================================================
621
- template <typename JsonType>
617
+ template <fly::SameAs<Json> JsonType>
622
618
bool JsonIterator<JsonType>::operator ==(const JsonIterator &iterator) const
623
619
{
624
620
validate_iterator (iterator);
625
621
return m_iterator == iterator.m_iterator ;
626
622
}
627
623
628
624
// ==================================================================================================
629
- template <typename JsonType>
625
+ template <fly::SameAs<Json> JsonType>
630
626
bool JsonIterator<JsonType>::operator !=(const JsonIterator &iterator) const
631
627
{
632
628
return !(*this == iterator);
633
629
}
634
630
635
631
// ==================================================================================================
636
- template <typename JsonType>
632
+ template <fly::SameAs<Json> JsonType>
637
633
bool JsonIterator<JsonType>::operator <(const JsonIterator &iterator) const
638
634
{
639
635
validate_iterator (iterator);
@@ -654,28 +650,28 @@ bool JsonIterator<JsonType>::operator<(const JsonIterator &iterator) const
654
650
}
655
651
656
652
// ==================================================================================================
657
- template <typename JsonType>
653
+ template <fly::SameAs<Json> JsonType>
658
654
bool JsonIterator<JsonType>::operator <=(const JsonIterator &iterator) const
659
655
{
660
656
return !(iterator < *this );
661
657
}
662
658
663
659
// ==================================================================================================
664
- template <typename JsonType>
660
+ template <fly::SameAs<Json> JsonType>
665
661
bool JsonIterator<JsonType>::operator >(const JsonIterator &iterator) const
666
662
{
667
663
return !(*this <= iterator);
668
664
}
669
665
670
666
// ==================================================================================================
671
- template <typename JsonType>
667
+ template <fly::SameAs<Json> JsonType>
672
668
bool JsonIterator<JsonType>::operator >=(const JsonIterator &iterator) const
673
669
{
674
670
return !(*this < iterator);
675
671
}
676
672
677
673
// ==================================================================================================
678
- template <typename JsonType>
674
+ template <fly::SameAs<Json> JsonType>
679
675
auto JsonIterator<JsonType>::operator ++(int ) -> JsonIterator
680
676
{
681
677
auto result = *this ;
@@ -685,7 +681,7 @@ auto JsonIterator<JsonType>::operator++(int) -> JsonIterator
685
681
}
686
682
687
683
// ==================================================================================================
688
- template <typename JsonType>
684
+ template <fly::SameAs<Json> JsonType>
689
685
auto JsonIterator<JsonType>::operator ++() -> JsonIterator &
690
686
{
691
687
validate_iterator ();
@@ -702,7 +698,7 @@ auto JsonIterator<JsonType>::operator++() -> JsonIterator &
702
698
}
703
699
704
700
// ==================================================================================================
705
- template <typename JsonType>
701
+ template <fly::SameAs<Json> JsonType>
706
702
auto JsonIterator<JsonType>::operator --(int ) -> JsonIterator
707
703
{
708
704
auto result = *this ;
@@ -712,7 +708,7 @@ auto JsonIterator<JsonType>::operator--(int) -> JsonIterator
712
708
}
713
709
714
710
// ==================================================================================================
715
- template <typename JsonType>
711
+ template <fly::SameAs<Json> JsonType>
716
712
auto JsonIterator<JsonType>::operator --() -> JsonIterator &
717
713
{
718
714
validate_iterator ();
@@ -729,7 +725,7 @@ auto JsonIterator<JsonType>::operator--() -> JsonIterator &
729
725
}
730
726
731
727
// ==================================================================================================
732
- template <typename JsonType>
728
+ template <fly::SameAs<Json> JsonType>
733
729
auto JsonIterator<JsonType>::operator +=(difference_type offset) -> JsonIterator &
734
730
{
735
731
validate_iterator ();
@@ -752,14 +748,14 @@ auto JsonIterator<JsonType>::operator+=(difference_type offset) -> JsonIterator
752
748
}
753
749
754
750
// ==================================================================================================
755
- template <typename JsonType>
751
+ template <fly::SameAs<Json> JsonType>
756
752
auto JsonIterator<JsonType>::operator -=(difference_type offset) -> JsonIterator &
757
753
{
758
754
return *this += -offset;
759
755
}
760
756
761
757
// ==================================================================================================
762
- template <typename JsonType>
758
+ template <fly::SameAs<Json> JsonType>
763
759
auto JsonIterator<JsonType>::operator +(difference_type offset) const -> JsonIterator
764
760
{
765
761
auto result = *this ;
@@ -769,7 +765,7 @@ auto JsonIterator<JsonType>::operator+(difference_type offset) const -> JsonIter
769
765
}
770
766
771
767
// ==================================================================================================
772
- template <typename JsonType>
768
+ template <fly::SameAs<Json> JsonType>
773
769
JsonIterator<JsonType> operator +(
774
770
typename JsonIterator<JsonType>::difference_type offset,
775
771
const JsonIterator<JsonType> &iterator)
@@ -781,7 +777,7 @@ JsonIterator<JsonType> operator+(
781
777
}
782
778
783
779
// ==================================================================================================
784
- template <typename JsonType>
780
+ template <fly::SameAs<Json> JsonType>
785
781
auto JsonIterator<JsonType>::operator -(difference_type offset) const -> JsonIterator
786
782
{
787
783
auto result = *this ;
@@ -791,7 +787,7 @@ auto JsonIterator<JsonType>::operator-(difference_type offset) const -> JsonIter
791
787
}
792
788
793
789
// ==================================================================================================
794
- template <typename JsonType>
790
+ template <fly::SameAs<Json> JsonType>
795
791
auto JsonIterator<JsonType>::operator -(const JsonIterator &iterator) const -> difference_type
796
792
{
797
793
validate_iterator (iterator);
@@ -812,7 +808,7 @@ auto JsonIterator<JsonType>::operator-(const JsonIterator &iterator) const -> di
812
808
}
813
809
814
810
// ==================================================================================================
815
- template <typename JsonType>
811
+ template <fly::SameAs<Json> JsonType>
816
812
const typename json_object_type::key_type &JsonIterator<JsonType>::key() const
817
813
{
818
814
validate_iterator ();
@@ -834,14 +830,14 @@ const typename json_object_type::key_type &JsonIterator<JsonType>::key() const
834
830
}
835
831
836
832
// ==================================================================================================
837
- template <typename JsonType>
833
+ template <fly::SameAs<Json> JsonType>
838
834
auto JsonIterator<JsonType>::value() const -> reference
839
835
{
840
836
return *(*this );
841
837
}
842
838
843
839
// ==================================================================================================
844
- template <typename JsonType>
840
+ template <fly::SameAs<Json> JsonType>
845
841
void JsonIterator<JsonType>::validate_iterator() const
846
842
{
847
843
if (m_json == nullptr )
@@ -851,7 +847,7 @@ void JsonIterator<JsonType>::validate_iterator() const
851
847
}
852
848
853
849
// ==================================================================================================
854
- template <typename JsonType>
850
+ template <fly::SameAs<Json> JsonType>
855
851
void JsonIterator<JsonType>::validate_iterator(const JsonIterator &iterator) const
856
852
{
857
853
validate_iterator ();
@@ -864,7 +860,7 @@ void JsonIterator<JsonType>::validate_iterator(const JsonIterator &iterator) con
864
860
}
865
861
866
862
// ==================================================================================================
867
- template <typename JsonType>
863
+ template <fly::SameAs<Json> JsonType>
868
864
template <typename T>
869
865
void JsonIterator<JsonType>::validate_offset(const T &it, difference_type offset) const
870
866
@@ -889,7 +885,7 @@ void JsonIterator<JsonType>::validate_offset(const T &it, difference_type offset
889
885
}
890
886
891
887
// ==================================================================================================
892
- template <typename JsonType>
888
+ template <fly::SameAs<Json> JsonType>
893
889
template <typename T>
894
890
void JsonIterator<JsonType>::validate_dereference(const T &it) const
895
891
{
0 commit comments