Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

[WIP] Disallow StringRef assignment from temporary std::strings. #29

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/llvm/ADT/StringRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ namespace llvm {
return Data[Index];
}

/// Disallow accidental assignment from a temporary std::string.
///
/// The declaration here is extra complicated so that `stringRef = {}`
/// and `stringRef = "abc"` continue to select the move assignment operator.
template <typename T>
typename std::enable_if<std::is_same<T, std::string>::value,
StringRef>::type &
operator=(T &&Str) = delete;

/// @}
/// @name Type Conversions
/// @{
Expand Down