remove constexpr since gcc 4.4 or vs2010 does not support it

pull/3065/head
yang-g 10 years ago
parent 887c094b0b
commit d5539ec6e2
  1. 28
      include/grpc++/support/string_ref.h
  2. 2
      src/cpp/util/string_ref.cc

@ -50,22 +50,22 @@ class string_ref {
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// constants
static constexpr size_t npos = size_t(-1);
static size_t npos = size_t(-1);
// construct/copy.
constexpr string_ref() : data_(nullptr), length_(0) {}
constexpr string_ref(const string_ref& other)
string_ref() : data_(nullptr), length_(0) {}
string_ref(const string_ref& other)
: data_(other.data_), length_(other.length_) {}
string_ref& operator=(const string_ref& rhs);
string_ref(const char* s);
constexpr string_ref(const char* s, size_t l) : data_(s), length_(l) {}
string_ref(const char* s, size_t l) : data_(s), length_(l) {}
string_ref(const grpc::string& s) : data_(s.data()), length_(s.length()) {}
// iterators
constexpr const_iterator begin() const { return data_; }
constexpr const_iterator end() const { return data_ + length_; }
constexpr const_iterator cbegin() const { return data_; }
constexpr const_iterator cend() const { return data_ + length_; }
const_iterator begin() const { return data_; }
const_iterator end() const { return data_ + length_; }
const_iterator cbegin() const { return data_; }
const_iterator cend() const { return data_ + length_; }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
@ -80,10 +80,10 @@ class string_ref {
}
// capacity
constexpr size_t size() const { return length_; }
constexpr size_t length() const { return length_; }
constexpr size_t max_size() const { return length_; }
constexpr bool empty() const { return length_ == 0; }
size_t size() const { return length_; }
size_t length() const { return length_; }
size_t max_size() const { return length_; }
bool empty() const { return length_ == 0; }
// element access
const char* data() const { return data_; }
@ -95,9 +95,7 @@ class string_ref {
size_t find(string_ref s) const;
size_t find(char c) const;
// Defined as constexpr in n3442 but C++11 constexpr semantics do not allow
// the implementation of this function to comply.
/* constrexpr */ string_ref substr(size_t pos, size_t n = npos) const;
string_ref substr(size_t pos, size_t n = npos) const;
private:
const char* data_;

@ -39,7 +39,7 @@
namespace grpc {
constexpr size_t string_ref::npos;
size_t string_ref::npos;
string_ref& string_ref::operator=(const string_ref& rhs) {
data_ = rhs.data_;

Loading…
Cancel
Save