From f61b6ec48ade4e071a8f65814f3a1d14373a0786 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 25 May 2019 15:43:08 +0200 Subject: Work arounds for VC 16.1 --- libbutl/url.mxx | 73 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/libbutl/url.mxx b/libbutl/url.mxx index d2360f0..357926b 100644 --- a/libbutl/url.mxx +++ b/libbutl/url.mxx @@ -388,36 +388,49 @@ LIBBUTL_MODEXPORT namespace butl // Also note that the characters are interpreted as bytes. In other words, // each character may result in a single encoding triplet. // - template + template static void - encode (I b, I e, - O o, + encode (I begin, I end, O output, F&& efunc); - // VC (as of 15u3) doesn't see unreserved() unless qualified. - // - F&& f = [] (char_type& c) {return !basic_url::unreserved (c);}); + template + static void + encode (I b, I e, O o) + { + encode (b, e, o, [] (char_type& c) {return !unreserved (c);}); + } - template + template static string_type - encode (const string_type& s, - F&& f = [] (char_type& c) {return !basic_url::unreserved (c);}) + encode (const string_type& s, F&& f) { string_type r; encode (s.begin (), s.end (), std::back_inserter (r), f); return r; } - template static string_type - encode (const char_type* s, - F&& f = [] (char_type& c) {return !basic_url::unreserved (c);}) + encode (const string_type& s) + { + return encode (s, [] (char_type& c) {return !unreserved (c);}); + } + + template + static string_type + encode (const char_type* s, F&& f) { string_type r; encode (s, s + string_type::traits_type::length (s), - std::back_inserter (r), f); + std::back_inserter (r), + f); return r; } + static string_type + encode (const char_type* s) + { + return encode (s, [] (char_type& c) {return !unreserved (c);}); + } + // URL-decode a character sequence. Throw std::invalid_argument if an // invalid encoding sequence is encountered. // @@ -425,29 +438,49 @@ LIBBUTL_MODEXPORT namespace butl // (rather than percent-encoded), then one must provide the callback // function to decode them. // - template + template static void - decode (I b, I e, O o, F&& f = [] (char_type&) {}); + decode (I begin, I end, O output, F&& dfunc); - template + template + static void + decode (I b, I e, O o) + { + decode (b, e, o, [] (char_type&) {}); + } + + template static string_type - decode (const string_type& s, F&& f = [] (char_type&) {}) + decode (const string_type& s, F&& f) { string_type r; decode (s.begin (), s.end (), std::back_inserter (r), f); return r; } - template static string_type - decode (const char_type* s, F&& f = [] (char_type&) {}) + decode (const string_type& s) + { + return decode (s, [] (char_type&) {}); + } + + template + static string_type + decode (const char_type* s, F&& f) { string_type r; decode (s, s + string_type::traits_type::length (s), - std::back_inserter (r), f); + std::back_inserter (r), + f); return r; } + static string_type + decode (const char_type* s) + { + return decode (s, [] (char_type&) {}); + } + private: bool empty_ = false; }; -- cgit v1.1