KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Needless to over explain. The following code is self-evident: struct X { X(int n){} }; int main() { std::vector<int> src; std::vector<X> dest; // Below is not valid in current C++, but that is just what I want. transform(src.begin(), src.end(), back_insert(dest), std::bind(&X::X, _1)); } A constructor takes some arguments and returns an object of the class of the constructor. A constructor looks like a function, acts like a function, and is exactly a function. So, I think std::bind should uniformly treat constructors and other callable objects. However, how can I extend the function template "bind" to implement that?
Tags (comma-separated)
Save Edits
Cancel