當前位置: 首頁>>代碼示例>>C++>>正文


C++ std::bind方法代碼示例

本文整理匯總了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)));
}
開發者ID:shilinf,項目名稱:381_5,代碼行數:7,代碼來源:Model.cpp

示例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));
}
開發者ID:aufgang001,項目名稱:my_routing,代碼行數:7,代碼來源:nfdc.cpp

示例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)));
}
開發者ID:shilinf,項目名稱:381_5,代碼行數:7,代碼來源:Model.cpp

示例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;
}
開發者ID:bluddy,項目名稱:K3-Core,代碼行數:8,代碼來源:throughput_benchmark.cpp

示例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;

}
開發者ID:neiwork,項目名稱:radproc,代碼行數:32,代碼來源:pairInjectionExact.cpp

示例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;

}
開發者ID:neiwork,項目名稱:radproc,代碼行數:27,代碼來源:pairInjection.cpp

示例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);
   }
開發者ID:Ichthyostega,項目名稱:Lumiera,代碼行數:60,代碼來源:multifact-test.cpp

示例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)));
}
開發者ID:spencewenski,項目名稱:sudoslide,代碼行數:8,代碼來源:Model.cpp

示例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));
 }
開發者ID:bregma,項目名稱:ginn,代碼行數:10,代碼來源:test_activewishes.cpp

示例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);
}
開發者ID:rnestler,項目名稱:Prog3,代碼行數:10,代碼來源:bind.cpp

示例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 ) ) );
}
開發者ID:robertdhernandez,項目名稱:custom-war,代碼行數:11,代碼來源:tile.cpp

示例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);
}
開發者ID:rnestler,項目名稱:Prog3,代碼行數:11,代碼來源:bind.cpp

示例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;
}
開發者ID:fosnola,項目名稱:libetonyek,代碼行數:12,代碼來源:KEY6Parser.cpp

示例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;
}
開發者ID:liloneum,項目名稱:Aegisub,代碼行數:52,代碼來源:audio_karaoke.cpp

示例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;
}
開發者ID:darvelo,項目名稱:data-structures-and-algorithms,代碼行數:13,代碼來源:find_articulation_vertices.cpp


注:本文中的std::bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。