[PATCH] D49985: [ADT] ImmutableList no longer requires elements to be copy constructible

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 6 10:24:05 PDT 2018


george.karpenkov added a comment.

> requires it's elements to be copy constructible for no good reason
>  It seems like ImmutableList doesn't run the destructor for std::unique_ptrs

Seems there was a reason: and ImmutableList and its members are assumed to be a POD (plain old datatype), which do not need destructors.

E.g. see the code at the bottom of ImmutableList.h:

  template <typename T> struct isPodLike;
  template <typename T>
  struct isPodLike<ImmutableList<T>> { static const bool value = true; };

@NoQ might want to correct me here, but I'm not sure how achievable is your use case, or whether it makes sense.
The point of functional ImmutableList is that you can copy them by value at O(1) cost everywhere.
If your list contains `unique_ptr` you can no longer copy it at all without violating `unique_ptr` semantics.


https://reviews.llvm.org/D49985





More information about the llvm-commits mailing list