Skip to content

Commit

Permalink
Fix WStringStream to accept const char strings
Browse files Browse the repository at this point in the history
  • Loading branch information
zachstruck-ordis committed Jun 26, 2018
1 parent a96e9e8 commit d3f53e5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Wt/WStringStream.C
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ WStringStream& WStringStream::operator<< (char c)
return *this;
}

WStringStream& WStringStream::operator<< (char *s)
WStringStream& WStringStream::operator<< (const char *s)
{
append(s, std::strlen(s));

Expand Down
20 changes: 1 addition & 19 deletions src/Wt/WStringStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,13 @@ class WT_API WStringStream
*/
void append(const char *s, int length);

#ifndef WT_TARGET_JAVA
/*
* Should not be implemented but is needed to support the specialization
* for string literals !
*/
template <typename T>
inline WStringStream& operator<< (T t) {
WStringStream please_cast_to_a_supported_type = t;
please_cast_to_a_supported_type << 'a'; // silence compiler for normal case
return *this;
}

template <std::size_t N>
WStringStream& operator<< (const char (&s)[N]) {
append(s, N-1); return *this;
}
#endif // WT_TARGET_JAVA

/*! \brief Appends a character.
*/
WStringStream& operator<< (char);

/*! \brief Appends a C string.
*/
WStringStream& operator<< (char *s);
WStringStream& operator<< (const char *s);

/*! \brief Appends a C++ string.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/web/EscapeOStream.C
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void EscapeOStream::append(const char *s, std::size_t len)
put(s, *this);
}

EscapeOStream& EscapeOStream::operator<< (char *s)
EscapeOStream& EscapeOStream::operator<< (const char *s)
{
if (c_special_ == 0)
stream_ << s;
Expand Down
16 changes: 1 addition & 15 deletions src/web/EscapeOStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,8 @@ class WT_API EscapeOStream
void append(const std::string& s, const EscapeOStream& rules);
void append(const char *s, std::size_t len);

#ifndef WT_TARGET_JAVA
/*
* Should not be implemented but is needed to support the specialization
* for string literals !
*/
template <typename T>
inline EscapeOStream& operator<< (T t);

template <std::size_t N>
EscapeOStream& operator<< (const char (&s)[N]) {
append(s, N-1); return *this;
}
#endif // WT_TARGET_JAVA

EscapeOStream& operator<< (char);
EscapeOStream& operator<< (char *s);
EscapeOStream& operator<< (const char *s);
EscapeOStream& operator<< (const std::string& s);
EscapeOStream& operator<< (int);
EscapeOStream& operator<< (long long);
Expand Down

0 comments on commit d3f53e5

Please sign in to comment.