本文整理汇总了C++中std::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ std::bind方法的具体用法?C++ std::bind怎么用?C++ std::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std
的用法示例。
在下文中一共展示了std::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attach
void Model::attach(shared_ptr<View> view)
{
view_container.insert(view);
for_each(object_container.begin(), object_container.end(),
bind(&Sim_object::broadcast_current_state,
bind(& map<string, shared_ptr<Sim_object> >::value_type::second, _1)));
}
示例2: bind
void
Nfdc::FaceIdFetcher::startGetFaceId(const ndn::util::FaceUri& faceUri)
{
faceUri.canonize(bind(&FaceIdFetcher::onCanonizeSuccess, this, _1),
bind(&FaceIdFetcher::onCanonizeFailure, this, _1),
m_face.getIoService(), ndn::time::seconds(4));
}
示例3: update
void Model::update()
{
++time;
for_each(object_container.begin(), object_container.end(),
bind(&Sim_object::update,
bind(& map<string, shared_ptr<Sim_object> >::value_type::second, _1)));
}
示例4: buildTable
// MP setup
TriggerDispatch buildTable(shared_ptr<Engine> engine) {
TriggerDispatch table = TriggerDispatch();
table["send_one"] = bind(&K3::send_one, engine, std::placeholders::_1);
table["receive_one"] = bind(&K3::receive_one, engine, std::placeholders::_1);
table["finished"] = bind(&K3::finished, engine, std::placeholders::_1);
return table;
}
示例5: pairInjectionExact
double pairInjectionExact(double E, Particle& particle, Particle& photon, fun1 tpf)
{
using std::bind; using namespace std::placeholders; // para _1, _2, etc.
double Erest = electronMass*cLight2;
double cte = 3.0*cLight*thomson*Erest/4.0; // *Erest^2: de las dos dist de fotones
// /Erest: de la inyeccion de electrones
//normalizo todo a me*c^2
double inf = targetPhotonEmin/Erest;
double sup = targetPhotonEmax/Erest;
/*DataInjection data;
data.E = E;
data.mass = electronMass;
data.tpf = tpf;*/
double integral = RungeKutta(inf,sup,
bind(cAnnihilationExact,_1,E,electronMass),
dAnnihilationExact,
bind(fAnnihilationExact,_1,_2,E,electronMass,tpf));
double emissivityA = cte*integral;
return emissivityA;
}
示例6: pairInjectionFlor
double pairInjectionFlor(double E, Particle& particle, Particle& photon, fun1 tpf)
{
using std::bind; using namespace std::placeholders; // para _1, _2, etc.
double cte = 3.0*cLight*thomson*pow((particle.mass*cLight2),4)/32.0;
double sup = 1.0; // 2e9*1.6e-12; //este es el infinito del limite superior para la integral en Egamma
//como Eph_min =0.15 keV --> Ega_max = 2 GeV
double inf = E; //Ega_min < Ee_min --> la condicion esta asegurada
//DataInjection data;
//data.E = E;
//data.mass = particle.mass;
//data.tpf = tpf;
double integral = RungeKutta(inf,sup,
bind(cAnnihilation,_1,E,particle.mass),
dAnnihilation,
bind(fAnnihilation,_1,_2,E,tpf));
double emissivityA = cte*integral;
return emissivityA;
}
示例7: backdoor
void
produce_simple_values()
{
using TestFactory = factory::MultiFact<string, theID>;
TestFactory theFact;
// the first "production line" is wired to a free function
theFact.defineProduction (ONE, buildOne);
// second "production line" uses a explicit partial closure
theFact.defineProduction (TWO, bind (buildSome<theID>, TWO));
// for the third "production line" we set up a function object
auto memberFunction = bind (&MultiFact_test::callMe, this, "lalü");
theFact.defineProduction (THR, memberFunction);
// and the fourth "production line" uses a lambda, closed with a local reference
string backdoor("backdoor");
theFact.defineProduction (FOU, [&] {
return backdoor;
});
CHECK (!isnil (theFact));
CHECK (theFact(ONE) == "1");
CHECK (theFact(TWO) == "2");
CHECK (theFact(THR) == "lalü");
CHECK (invocations_ == 1);
CHECK (theFact(FOU) == "backdoor");
backdoor = "I am " + backdoor.substr(0,4);
CHECK (theFact(FOU) == "I am back");
TestFactory anotherFact;
CHECK (isnil (anotherFact));
VERIFY_ERROR (INVALID, anotherFact(ONE) );
anotherFact.defineProduction (ONE, memberFunction);
CHECK (anotherFact(ONE) == "lalü");
CHECK (invocations_ == 2);
CHECK (theFact(THR) == "lalü");
CHECK (invocations_ == 3);
CHECK ( theFact.contains (FOU));
CHECK (!anotherFact.contains (FOU));
anotherFact = theFact;
CHECK (anotherFact.contains (FOU));
CHECK (!isSameObject(theFact, anotherFact));
CHECK (anotherFact(ONE) == "1");
CHECK (anotherFact(TWO) == "2");
CHECK (anotherFact(THR) == "lalü");
CHECK (anotherFact(FOU) == "I am back");
CHECK (invocations_ == 4);
}
示例8: attach_view
void Model::attach_view(View_ptr_t view_ptr)
{
views.insert(view_ptr);
// add bind
for_each(boards.begin(), boards.end(),
bind(&Board::broadcast_state,
bind(&Board_map_t::value_type::second, _1)));
}
示例9: ActiveWishesTest
ActiveWishesTest()
: wish_source_(WishSource::factory(&Environment::config()))
, active_wishes_(Environment::config(), &gesture_source_)
{
app_source_.set_initialized_callback(bind(&ActiveWishesTest::app_source_initialized, this));
app_source_.set_window_opened_callback(bind(&ActiveWishesTest::window_opened, this, _1));
app_source_.set_window_closed_callback(bind(&ActiveWishesTest::window_closed, this, _1));
active_wishes_.set_wish_granted_callback(bind(&ActiveWishesTest::callback_counter, this, _1, _2));
active_wishes_.set_wish_revoked_callback(bind(&ActiveWishesTest::callback_counter, this, _1, _2));
}
示例10: sqrtSquare
void sqrtSquare() {
double x = 7;
double result = sqrt(x * x);
auto square = getSquare<double>();
auto func = bind( sqrt, bind(square,_1) );
ASSERT_EQUAL(func(x), result);
}
示例11: INIT_TILES
void INIT_TILES()
{
if ( !TILES.empty() ) return;
using std::bind;
using std::make_pair;
using namespace std::placeholders;
TILES.insert( make_pair( "plains", bind( CREATE_TILE< tile::Plains >, _1, _2 ) ) );
TILES.insert( make_pair( "road", bind( CREATE_TILE< tile::Road >, _1, _2 ) ) );
}
示例12: squareModulo
void squareModulo() {
int x = 7;
int y = 2;
int result = (x * x) % y;
auto square = getSquare<unsigned>();
auto func = bind(modulus<unsigned>{}, bind(square, _1), _2);
ASSERT_EQUAL(func(x,y), result);
}
示例13: msg
bool KEY6Parser::parseSlideList(const unsigned id)
{
const ObjectMessage msg(*this, id, KEY6ObjectType::SlideList);
if (!msg)
return false;
const deque<unsigned> &slideListRefs = readRefs(get(msg), 1);
for_each(slideListRefs.begin(), slideListRefs.end(), bind(&KEY6Parser::parseSlideList, this, _1));
const deque<unsigned> &slideRefs = readRefs(get(msg), 2);
for_each(slideRefs.begin(), slideRefs.end(), bind(&KEY6Parser::parseSlide, this, _1, false));
return true;
}
示例14: wxWindow
AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
: wxWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_SUNKEN)
, c(c)
, file_changed(c->ass->AddCommitListener(&AudioKaraoke::OnFileChanged, this))
, audio_opened(c->audioController->AddAudioOpenListener(&AudioKaraoke::OnAudioOpened, this))
, audio_closed(c->audioController->AddAudioCloseListener(&AudioKaraoke::OnAudioClosed, this))
, active_line_changed(c->selectionController->AddActiveLineListener(&AudioKaraoke::OnActiveLineChanged, this))
, active_line(nullptr)
, kara(agi::util::make_unique<AssKaraoke>())
, scroll_x(0)
, scroll_dir(0)
, char_height(0)
, char_width(0)
, mouse_pos(0)
, click_will_remove_split(false)
, enabled(false)
{
using std::bind;
cancel_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_cancel_16));
cancel_button->SetToolTip(_("Discard all uncommitted splits"));
cancel_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, bind(&AudioKaraoke::CancelSplit, this));
accept_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_accept_16));
accept_button->SetToolTip(_("Commit splits"));
accept_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, bind(&AudioKaraoke::AcceptSplit, this));
split_area = new wxPanel(this);
wxSizer *main_sizer = new wxBoxSizer(wxHORIZONTAL);
main_sizer->Add(cancel_button);
main_sizer->Add(accept_button);
main_sizer->Add(split_area, wxSizerFlags(1).Expand());
SetSizerAndFit(main_sizer);
/// @todo subscribe
split_font.SetFaceName(to_wx(OPT_GET("Audio/Karaoke/Font Face")->GetString()));
split_font.SetPointSize(OPT_GET("Audio/Karaoke/Font Size")->GetInt());
split_area->Bind(wxEVT_SIZE, &AudioKaraoke::OnSize, this);
split_area->Bind(wxEVT_PAINT, &AudioKaraoke::OnPaint, this);
split_area->Bind(wxEVT_LEFT_DOWN, &AudioKaraoke::OnMouse, this);
split_area->Bind(wxEVT_LEFT_UP, &AudioKaraoke::OnMouse, this);
split_area->Bind(wxEVT_MOTION, &AudioKaraoke::OnMouse, this);
split_area->Bind(wxEVT_LEAVE_WINDOW, &AudioKaraoke::OnMouse, this);
split_area->Bind(wxEVT_CONTEXT_MENU, &AudioKaraoke::OnContextMenu, this);
scroll_timer.Bind(wxEVT_TIMER, &AudioKaraoke::OnScrollTimer, this);
accept_button->Enable(false);
cancel_button->Enable(false);
enabled = false;
}
示例15: result
ArticulationResult<GraphT>
find_articulation_vertices(GraphT& g) {
g.initializeSearch();
ArticulationResult<GraphT> result(g);
auto pEarly = bind(&ArticulationResult<GraphT>::processEarly, ref(result), _1);
auto pLate = bind(&ArticulationResult<GraphT>::processLate, ref(result), _1);
auto pEdge = bind(&ArticulationResult<GraphT>::processEdge, ref(result), _1, _2);
g.dfs("v1", pEarly, pLate, pEdge);
return result;
}