[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 17:21:30 PST 2017


EricWF added inline comments.


================
Comment at: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:57
+  { // Testing (2)
+    // FIXME: (2) doesn't work with implicit deduction.
+    // const test_allocator<char> alloc{};
----------------
rsmith wrote:
> I think that at least matches the standard as-is. I'm not sure this case is worth adding an explicit deduction guide for. *shrug*
I agree this probably matches the standard as-is, and that it's probably not worth adding an explicit guide for.
In general I don't think libc++ should add *any* explicit guides until the are required by the standard.

I'll remove the FIXME and clarify the comment before committing.



================
Comment at: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:107
+  { // Testing (5) w/o allocator
+#if 0 // FIXME: This doesn't work
+    const std::string sin("abc");
----------------
rsmith wrote:
> Do you know why not?
Yeah. It seems to choose the `basic_string(size_type, CharT, const Allocator&)` overload after deducing `CharT` and `Allocator` to be `unsigned long`.

The compiler diagnostics produced are:
```
/home/eric/workspace/libcxx/include/memory:1494:22: error: type 'allocator_type' (aka 'unsigned long') cannot be used prior to '::' because it has no members
    typedef typename allocator_type::value_type value_type;
                     ^
/home/eric/workspace/libcxx/include/string:788:28: note: in instantiation of template class 'std::__1::allocator_traits<unsigned long>' requested here
    basic_string(size_type __n, _CharT __c, const _Allocator& __a);
                           ^
/home/eric/workspace/libcxx/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:111:23: note: while substituting deduced template arguments into function template '<deduction guide for basic_string>' [with _CharT = unsigned long, _Traits = (no value), _Allocator = unsigned long]
    std::basic_string s(sin, (size_t)1, (size_t)3);
 ```


================
Comment at: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:291
+  { // Testing (15)
+    // FIXME: This overload is broken. Fix it and add tests.
+  }
----------------
rsmith wrote:
> I think the inability to deduce using this overload matches the standard. I don't think there's any way in general to map the type `T` to a `charT`.
OK. I'll update the comment before committing. 


https://reviews.llvm.org/D29863





More information about the cfe-commits mailing list