Commit ce979260 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Delete the non-char integeral forms of fbstring::operator=

Summary: They allow for assignments that make no sense, so make it impossible to do so.

Reviewed By: yfeldblum

Differential Revision: D4919606

fbshipit-source-id: 24d8e036eff33a8c6def4672c0d098f0edd5c5b3
parent 5699919f
...@@ -1230,7 +1230,15 @@ public: ...@@ -1230,7 +1230,15 @@ public:
return assign(s); return assign(s);
} }
basic_fbstring& operator=(value_type c); // This actually goes directly against the C++ spec, but the
// value_type overload is dangerous, so we're explicitly deleting
// any overloads of operator= that could implicitly convert to
// value_type.
template <typename TP>
typename std::enable_if<
std::is_same<typename std::decay<TP>::type, value_type>::value,
basic_fbstring&>::type
operator=(TP c);
basic_fbstring& operator=(std::initializer_list<value_type> il) { basic_fbstring& operator=(std::initializer_list<value_type> il) {
return assign(il.begin(), il.end()); return assign(il.begin(), il.end());
...@@ -1860,8 +1868,13 @@ inline basic_fbstring<E, T, A, S>& basic_fbstring<E, T, A, S>::operator=( ...@@ -1860,8 +1868,13 @@ inline basic_fbstring<E, T, A, S>& basic_fbstring<E, T, A, S>::operator=(
} }
template <typename E, class T, class A, class S> template <typename E, class T, class A, class S>
inline basic_fbstring<E, T, A, S>& basic_fbstring<E, T, A, S>::operator=( template <typename TP>
const value_type c) { inline typename std::enable_if<
std::is_same<
typename std::decay<TP>::type,
typename basic_fbstring<E, T, A, S>::value_type>::value,
basic_fbstring<E, T, A, S>&>::type
basic_fbstring<E, T, A, S>::operator=(TP c) {
Invariant checker(*this); Invariant checker(*this);
if (empty()) { if (empty()) {
......
...@@ -208,7 +208,8 @@ template <class String> void clause11_21_4_2_lprime(String & test) { ...@@ -208,7 +208,8 @@ template <class String> void clause11_21_4_2_lprime(String & test) {
} }
template <class String> void clause11_21_4_2_m(String & test) { template <class String> void clause11_21_4_2_m(String & test) {
// Assignment from char // Assignment from char
test = random('a', 'z'); using value_type = typename String::value_type;
test = random(static_cast<value_type>('a'), static_cast<value_type>('z'));
} }
template <class String> void clause11_21_4_2_n(String & test) { template <class String> void clause11_21_4_2_n(String & test) {
// Assignment from initializer_list<char> // Assignment from initializer_list<char>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment