This is an archive of the discontinued LLVM Phabricator instance.

Remove std::tuple's reduced-arity-extension on implicit constructors.
AbandonedPublic

Authored by EricWF on Aug 15 2016, 1:04 AM.

Details

Summary

The reduced-arity-extension on tuple's implicit constructors breaks conforming code. eg

#include <tuple>
#include <string>
using namespace std;
int count(tuple<string, string>) { return 2; }
int count(tuple<string, string, string>) { return 3; }

int main() {
  int c = count({"abc", "def"}); // expected-error {{call to 'count' is ambiguous}}
}

To fix this the I removed the reduced-arity-extension only on the implicit constructors. This breaks the following code:

std::tuple<int, int, int> foo() { return {1, 2}  }

But it still allows for

using Tup = std::tuple<int, int, int>;
Tup foo() { return Tup{1, 2}; }

@Marshall should we provide a way to turn this ctor back on in case in breaks a bunch of real-world code? Maybe deprecate it for a release?

See also:

Diff Detail

Event Timeline

EricWF updated this revision to Diff 67998.Aug 15 2016, 1:04 AM
EricWF retitled this revision from to Remove std::tuple's reduced-arity-extension on implicit constructors..
EricWF updated this object.
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: cfe-commits.
EricWF updated this revision to Diff 68001.Aug 15 2016, 1:06 AM

Add missing test case.

EricWF abandoned this revision.Dec 27 2016, 10:48 PM

Another version of this has already been committed.