News for hackers. Stuff that matters.
Re:Why your first Rust FizzBuzz implementation may not work by pbsd on Sunday October 12, 2014 @11:13PM (#8447358)
The C++ analogous, although not exactly the same, is to use a `make_vector` wrapper, like

  template<typename...Args>
  inline auto make_vector(Args&&...args) {
    using T = typename std::common_type<Args...>::type;
    return std::vector<T>{{std::forward<Args>(args)...}};
  }
  ...
  auto v = make_vector("asd", "dsa", std::string("asdsa"));
It will obviously not deduce types after the vector is declared, but it's as close as one gets to type deduction based on the vector's content.

There is one instance in C++ where information does flow backwards in a sense: disambiguating template overloads. For example,

  using fn_type = std::vector<int>(&)(int&&,int&&,int&&);
  auto v = static_cast<fn_type>(make_vector)(1, 2, 3);
In this case, the static_cast information flows "back" to the type deduction of `make_vector` to deduce what Args&& is. This is not very useful, just a curiosity.

There are no comments on this comment yet.