@@ -70,10 +70,6 @@ inline bool has_key(const value &v, const std::string &key) noexcept;
7070inline bool has_key (const object &o, const std::string &key) noexcept ;
7171
7272// create a value from some JSON
73- template <class In >
74- inline value parse (In first, In last);
75- inline value parse (std::istream &is);
76- inline value parse (std::istream &&is);
7773inline value parse (std::string_view s);
7874
7975// convert a value to a JSON string
@@ -416,7 +412,6 @@ class object {
416412 friend bool operator ==(const object &lhs, const object &rhs) noexcept ;
417413 friend bool operator !=(const object &lhs, const object &rhs) noexcept ;
418414
419- template <class In >
420415 friend class parser ;
421416
422417private:
@@ -661,7 +656,6 @@ class value {
661656 friend bool operator ==(const value &lhs, const value &rhs);
662657 friend bool operator !=(const value &lhs, const value &rhs);
663658
664- template <class In >
665659 friend class parser ;
666660
667661private:
@@ -915,11 +909,10 @@ inline value &array::at(std::size_t n) {
915909/* *
916910 * @brief The parser class
917911 */
918- template <class In >
919912class parser {
920913public:
921- parser (In first, In last )
922- : begin_(first) , cur_(first) , end_(last ) {
914+ parser (std::string_view s )
915+ : begin_(s.begin()) , cur_(s.begin()) , end_(s.end() ) {
923916 }
924917
925918public:
@@ -1132,28 +1125,14 @@ class parser {
11321125 }
11331126
11341127private:
1135- In begin_;
1136- In cur_;
1137- In end_;
1128+ std::string_view::const_iterator begin_;
1129+ std::string_view::const_iterator cur_;
1130+ std::string_view::const_iterator end_;
11381131
11391132 int line_ = 1 ;
11401133 int column_ = 0 ;
11411134};
11421135
1143- template <class In >
1144- value parse (In first, In last) {
1145-
1146- parser<In> p (first, last);
1147-
1148- try {
1149- return p.parse ();
1150- } catch (exception &e) {
1151- e.line = p.line ();
1152- e.column = p.column ();
1153- throw ;
1154- }
1155- }
1156-
11571136inline std::string to_string (const value &v) {
11581137 return as_string (v);
11591138}
@@ -1253,16 +1232,16 @@ inline bool has_key(const object &o, const std::string &key) noexcept {
12531232 return o.find (key) != o.end ();
12541233}
12551234
1256- inline value parse (std::istream &&is) {
1257- return parse (is);
1258- }
1259-
1260- inline value parse (std::istream &is) {
1261- return parse (std::istreambuf_iterator<char >{is}, std::istreambuf_iterator<char >{});
1262- }
1263-
12641235inline value parse (std::string_view s) {
1265- return parse (s.begin (), s.end ());
1236+ parser p (s);
1237+
1238+ try {
1239+ return p.parse ();
1240+ } catch (exception &e) {
1241+ e.line = p.line ();
1242+ e.column = p.column ();
1243+ throw ;
1244+ }
12661245}
12671246
12681247inline bool is_string (const value &v) noexcept {
@@ -2123,11 +2102,10 @@ inline bool operator!=(const array &lhs, const array &rhs) noexcept {
21232102}
21242103
21252104/* *
2126- * @brief parser<In> ::get_string
2105+ * @brief parser::get_string
21272106 * @return
21282107 */
2129- template <class In >
2130- std::string parser<In>::get_string() {
2108+ std::string parser::get_string () {
21312109
21322110 if (read () != Quote) {
21332111 throw string_expected ();
@@ -2229,11 +2207,10 @@ std::string parser<In>::get_string() {
22292207}
22302208
22312209/* *
2232- * @brief parser<In> ::get_number
2210+ * @brief parser::get_number
22332211 * @return
22342212 */
2235- template <class In >
2236- std::string parser<In>::get_number() {
2213+ std::string parser::get_number () {
22372214 std::string s;
22382215 s.reserve (10 );
22392216 std::back_insert_iterator<std::string> out = back_inserter (s);
0 commit comments