[PATCH] D103888: [ADT] Remove APInt/APSInt toString() std::string variants

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 11 12:00:37 PDT 2021


dblaikie added a comment.

In D103888#2813236 <https://reviews.llvm.org/D103888#2813236>, @RKSimon wrote:

> In D103888#2811305 <https://reviews.llvm.org/D103888#2811305>, @dblaikie wrote:
>
>> Sounds OK.
>>
>> I wouldn't mind the places that can use op<< to use that - not sure preserving the explicit radix argument is super high value. (I think people would generally assume that's the default)
>> Possible we could call it `to_string`, is std::to_string meant to be an ADL extension point, so that other types expose a to_string in their own associated namespace, etc?
>
> We already have a llvm::to_string(V) wrapper inside ScopedPrinter.h that uses a temp llvm::raw_string_ostream to create the string - do you think that'd be good enough?

That's a weird place for such a general purpose/name template to live... but sort of.

What I mean is you could overload to_string to do the efficient thing - rather than having to stream it out, then come back to a string again. That way generic code would get the efficient behavior without intermediate streams.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103888/new/

https://reviews.llvm.org/D103888



More information about the cfe-commits mailing list