How to put a shell of a function with some arguments from local variables in a container with MSVC2015?

I looked at the answer to another question . However, I cannot understand, based on this example, why I can not associate the value of some local variable with the MSVC 2015 compiler? It just throws an error, and gcc 5.3 compiles it to msys2 / mingw64. I mean, as in

#include <iostream>
#include <functional>
#include <vector>

int add(int a, int b) { return a + b; }

using bound_add_t = decltype(std::bind(add, std::placeholders::_1, int()));

int main() {
  std::vector<bound_add_t> vec;
  int y = 2;
  vec.emplace_back(add,std::placeholders::_1, y); // <- this causes the problem
  vec.emplace_back(add,std::placeholders::_1, 2);
  vec.emplace_back(add,std::placeholders::_1, 3);

  for (auto &b : vec)
    std::cout << b(5) << std::endl;

  return 0;   
}

Severity Code Description Project File Line Suppression State Error C2664 'std :: _ Binder &, int> :: _ Binder (std :: _ Binder &, int> &)': cannot convert argument 3 from 'int' to 'int & & 'C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ include \ xmemory0 655

-? , . ?

, , , , .

++ 14? http://ideone.com/Zi1Yht. MSVC , , ++ 14, .

2

std::vector<std::function<int(int)> > vec;
vec.emplace_back(add, std::placeholders::_1, y);

,

C2664 'std:: function:: function (std:: function & &)': 1 'int (__cdecl &) (int, int)' 'std:: allocator_arg_t' C:\ (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0 655

+4
2

std::bind .

- .

(, ,...), , , .

std::vector<std::function<int(int)> > vec;
int y = 2;

vec.push_back(std::bind(add, std::placeholders::_1, y));
vec.push_back(std::bind(add, std::placeholders::_1, 2));
vec.push_back(std::bind(add, std::placeholders::_1, 3));
0

MSVC . int() , Args&&... int&&. , bind int&& , y rvalue, .

, bind .

std::function, const int&:

using bound_add_t = decltype(std::bind(add, std::placeholders::_1, std::declval<const int&>()));
+1

All Articles