I read the item34: prefer lambdas to std::bind of "modern effective C++", it says
Fixing the problem requires telling std::bind to defer evaluation of the expression until setAlarm is called, and the way to do that is to nest a second call to std::bind inside the first one:
so I wrtie the following code to test
#include <bits/stdc++.h>
#include <boost/type_index.hpp>
#include <memory>
using namespace std;
using Time = std::chrono::steady_clock::time_point;
enum class Sound
{
    Beep,
    Siren,
    Whistle
};
using Duration = std::chrono::steady_clock::duration;
template <typename T>
std::underlying_type_t<T> printEnum(T const value)
{
    return static_cast<std::underlying_type_t<T>>(value);
}
void setAlarm(Time t, Sound s, Duration d)
{
    cout << "time:" << t.time_since_epoch().count() << "  ring"
         << "  duraion:" << (std::chrono::duration_cast<std::chrono::seconds>(d)).count()
         << "  sound:" << static_cast<typename std::underlying_type<Sound>::type>(s)
         << "  sound:" << printEnum(s)
         << endl;
}
int main()
{
    using namespace std::chrono; 
    using namespace std::literals;
    using namespace std::placeholders; 
    auto setSoundB = std::bind(setAlarm,
                               std::bind(std::plus<>(), steady_clock::now(), 1h), _1, seconds(30));
    cout << "function calc time:" << steady_clock::now().time_since_epoch().count() << endl;
    setSoundB(Sound::Beep);
    cout << "function calc time:" << steady_clock::now().time_since_epoch().count() << endl;
    setSoundB(Sound::Beep);
    return 0;
}
but I get the following result:
function calc time:1670995052139460000
time:1670998652139145000  ring  duraion:30  sound:0  sound:0
function calc time:1670995052139480000
time:1670998652139145000  ring  duraion:30  sound:0  sound:0
why the time is same, it seems that the expression still evaluated when std::bind is called?
 
     
    