Tidy up usage of std::begin, std::end

This commit is contained in:
Vinnie Falco
2014-12-19 08:35:26 -08:00
parent 16021591b2
commit c01b4e6baa
3 changed files with 19 additions and 12 deletions

View File

@@ -20,11 +20,12 @@
#ifndef BEAST_HTTP_RFC2616_H_INCLUDED #ifndef BEAST_HTTP_RFC2616_H_INCLUDED
#define BEAST_HTTP_RFC2616_H_INCLUDED #define BEAST_HTTP_RFC2616_H_INCLUDED
#include <boost/regex.hpp>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <iterator>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <boost/regex.hpp>
namespace beast { namespace beast {
@@ -130,8 +131,8 @@ trim (String const& s)
{ {
using std::begin; using std::begin;
using std::end; using std::end;
auto first (begin(s)); auto first = begin(s);
auto last (end(s)); auto last = end(s);
std::tie (first, last) = trim (first, last); std::tie (first, last) = trim (first, last);
return { first, last }; return { first, last };
} }

View File

@@ -21,15 +21,16 @@
#define BEAST_LEXICALCAST_H_INCLUDED #define BEAST_LEXICALCAST_H_INCLUDED
#include <beast/Config.h> #include <beast/Config.h>
#include <beast/cxx14/type_traits.h> // <type_traits>
#include <algorithm> #include <algorithm>
#include <cerrno> #include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <iostream>
#include <iterator>
#include <limits> #include <limits>
#include <string> #include <string>
#include <utility> #include <beast/cxx14/type_traits.h> // <type_traits>
#include <typeinfo> #include <typeinfo>
#include <iostream> #include <utility>
namespace beast { namespace beast {
@@ -169,14 +170,14 @@ struct LexicalCast <Out, std::string>
std::enable_if_t <std::is_unsigned <Integral>::value, bool> std::enable_if_t <std::is_unsigned <Integral>::value, bool>
operator () (Integral& out, std::string const& in) const operator () (Integral& out, std::string const& in) const
{ {
return parseUnsigned (out, std::begin(in), std::end(in)); return parseUnsigned (out, in.begin(), in.end());
} }
template <class Integral = Out> template <class Integral = Out>
std::enable_if_t <std::is_signed <Integral>::value, bool> std::enable_if_t <std::is_signed <Integral>::value, bool>
operator () (Integral& out, std::string const& in) const operator () (Integral& out, std::string const& in) const
{ {
return parseSigned (out, std::begin(in), std::end(in)); return parseSigned (out, in.begin(), in.end());
} }
bool bool

View File

@@ -23,6 +23,7 @@
#include <beast/cxx14/algorithm.h> // <algorithm> #include <beast/cxx14/algorithm.h> // <algorithm>
#include <beast/cxx14/type_traits.h> // <type_traits> #include <beast/cxx14/type_traits.h> // <type_traits>
#include <cctype> #include <cctype>
#include <iterator>
#include <locale> #include <locale>
#include <string> #include <string>
@@ -37,9 +38,11 @@ struct ci_less
bool bool
operator() (String const& lhs, String const& rhs) const operator() (String const& lhs, String const& rhs) const
{ {
typedef typename String::value_type char_type; using std::begin;
return std::lexicographical_compare (std::begin(lhs), std::end(lhs), using std::end;
std::begin(rhs), std::end(rhs), using char_type = typename String::value_type;
return std::lexicographical_compare (
begin(lhs), end(lhs), begin(rhs), end(rhs),
[] (char_type lhs, char_type rhs) [] (char_type lhs, char_type rhs)
{ {
return std::tolower(lhs) < std::tolower(rhs); return std::tolower(lhs) < std::tolower(rhs);
@@ -54,7 +57,9 @@ std::enable_if_t<std::is_same<typename Lhs::value_type, char>::value &&
std::is_same<typename Lhs::value_type, char>::value, bool> std::is_same<typename Lhs::value_type, char>::value, bool>
ci_equal(Lhs const& lhs, Rhs const& rhs) ci_equal(Lhs const& lhs, Rhs const& rhs)
{ {
return std::equal (lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), using std::begin;
using std::end;
return std::equal (begin(lhs), end(lhs), begin(rhs), end(rhs),
[] (char lhs, char rhs) [] (char lhs, char rhs)
{ {
return std::tolower(lhs) == std::tolower(rhs); return std::tolower(lhs) == std::tolower(rhs);