[Solved] Unable to add std::placeholders namespace

Hello everyone,

I’m trying to add “std::placeholders” namespace in my code to use “std::bind”, but I get following error:
error: 'placeholders' is not a namespace-name

I’ve been trying a lot of things and looking for the solution on internet for hours without success.

I created a new project and I got the same error.
This empty project has the basic code and the basic configuration.


using namespace std::placeholders;
#include <Arduino.h>

void setup() {

void loop() {


platform = espressif32
board = az-delivery-devkit-v4
framework = arduino

I found on another post that “std::placeholders” is available from C++11 version.
To check it, I cleaned and compiled the project again using “verbose build” and I checked that “-std=gnu++11” was present as a compiler argument.

So, now that I have reduce the problem to a empty project and a basic configuration, I don’t know what else I could check.

As additional information, I also checked I’m using the last Platformio version (v2.5.5), and I use it on Windows 10.

Any ideas? Thank you!


Hello, I replay myself as I finally managed to find out how to use std::bind properly.
I leave here this just if it can help someone.

The solution was very simple: instead of adding “using namespace std::placeholders” at the begining of the file, it should be added after the “includes”.
And, acording so some pleople, best if it’s used in a local scope inside the corresponding function.
So I added it before the lines where “std::bind” is used.

The code would be like follows. I use it inside a class to asign two methods to two callbacks one with two ints as parameters, and the other without parameters:

#include <Arduino.h>

// Constructor of "ClassA". "Class A" is derived from "BaseClass"
    // Base class callback asignations using "std::bind"
    using namespace std::placeholders;
    // First callback on base class (two int parameters, returns void)
    Callback1Base = std::bind(&DerivedClass::Function1, this, _1, _2);
    // Second callback on base class (no parameters, returns void)
    Callback2Base= std::bind(&DerivedClass::Function2, this);

void DerivedClass::Function1(int a, int b){

void DerivedClass::Function2(){

Why is the using declaration before the include? It doesn’t know anythnig about the std::placeholder namespace at that point…

You are right, that was the mistake.

I found some people recommend just not to use “using”. So, because of that, I added it inside the function as a local scope instead of a global scope.