Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bind is not a member of std

Tags:

c++

I am using netbeans 7.2.1 with minwg compiler. I am getting the following error messages when trying to build the application:

error: 'function' in namespace 'std' does not name a type

error: 'bind' is not a member of 'std'

although I included functional.h in the begining of the file, and I am using 'function' and 'bind' in the form of: std::function and std::bind

Where is the problem? Is it in the compiler or there is something missing? I remember that I compiled and ran the same application successfully on visual studio 2010.

like image 499
user1638717 Avatar asked Jan 10 '13 15:01

user1638717


People also ask

What is STD bind?

std::bind is a Standard Function Objects that acts as a Functional Adaptor i.e. it takes a function as input and returns a new function Object as an output with with one or more of the arguments of passed function bound or rearranged.

Why BIND is used in C++?

Bind function with the help of placeholders helps to manipulate the position and number of values to be used by the function and modifies the function according to the desired output. What are placeholders? Placeholders are namespaces that direct the position of a value in a function.

How does STD bind work?

Internally, std::bind() detects that a pointer to a member function is passed and most likely turns it into a callable objects, e.g., by use std::mem_fn() with its first argument.

What is the return type of std :: bind?

std::bind return type The return type of std::bind holds a member object of type std::decay<F>::type constructed from std::forward<F>(f), and one object per each of args... , of type std::decay<Arg_i>::type, similarly constructed from std::forward<Arg_i>(arg_i).


1 Answers

It is not functional.h, it is just functional.

#include <functional> //without .h

Note that std::function and std::bind come with C++11 only. So you might have to upgrade your compiler in case you have not done yet.

Also, compile your code with -std=c++11 option:

$ g++ -std=c++11 file.cpp

That should work if you've upgraded your compiler. If your compiler is a bit old, you can also try -std=c++0x instead.

like image 91
Nawaz Avatar answered Sep 28 '22 12:09

Nawaz