[llvm] r187166 - Add a bool->StringRef c'tor to StringRef.

David Blaikie dblaikie at gmail.com
Fri Jul 26 11:31:47 PDT 2013


On Thu, Jul 25, 2013 at 4:06 PM, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Thu Jul 25 18:06:39 2013
> New Revision: 187166
>
> URL: http://llvm.org/viewvc/llvm-project?rev=187166&view=rev
> Log:
> Add a bool->StringRef c'tor to StringRef.

FWIW I was more expecting this to be a free function - not sure it
really deserves to be a StringRef ctor, even if it's explicit. Would
make the usage of this a little bit subtle. A "toString" or something
might be a bit more legible.

Not going to make any absolute claims here, so do whatever you think
is best - just thoughts.

>
> Modified:
>     llvm/trunk/include/llvm/ADT/StringRef.h
>
> Modified: llvm/trunk/include/llvm/ADT/StringRef.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=187166&r1=187165&r2=187166&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/StringRef.h (original)
> +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Jul 25 18:06:39 2013
> @@ -90,6 +90,10 @@ namespace llvm {
>      /*implicit*/ StringRef(const std::string &Str)
>        : Data(Str.data()), Length(Str.length()) {}
>
> +    /// Construct a string ref from a boolean.
> +    explicit StringRef(bool B)
> +      : Data(B ? "true" : "false"), Length(::strlen(Data)) {}
> +
>      /// @}
>      /// @name Iterators
>      /// @{
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list