1

I have the following class interface:

template <typename D, typename... Cs>
struct Foo {
  
  Foo(int other_variable, Cs&&... cs) : 
    tuple {std::make_tuple(std::forward<Cs>(cs)...)} {
  }

  std::tuple<Cs...> tuple;
};

It fails to compile with the following code:

Foo<float> foo(1, 
  []()            { /* lambda type 1 */ },
  [](std::string) { /* lambda type 2 */ },
  [](int)         { /* lambda type 3 */ }
);

I had the impression that I need to provide a deduction guide but the following guide doesn't work:

template <typename D, typename... Cs> Foo(int, Cs&&...) -> Foo<D, Cs...>;
cigien
  • 57,834
  • 11
  • 73
  • 112
Jes
  • 2,614
  • 4
  • 25
  • 45
  • 2
    Reading around a bit, this is a duplicate of [c++ - C++17 class template partial deduction - Stack Overflow](https://stackoverflow.com/questions/41833630/c17-class-template-partial-deduction) -- there's no way except writing a helper `make_` function. – user202729 Oct 12 '21 at 05:37
  • @Elliott Wrong link – user202729 Oct 12 '21 at 05:45
  • 1
    @Elliott That's a different problem, see the error message. – user202729 Oct 12 '21 at 05:48

0 Answers0