Skip to content

Instantly share code, notes, and snippets.

@t-f-m
Created March 8, 2012 02:44
Show Gist options
  • Save t-f-m/1998216 to your computer and use it in GitHub Desktop.
Save t-f-m/1998216 to your computer and use it in GitHub Desktop.
http://www.kmonos.net/alang/boost/classes/thread.html のsampleからboost::ref依存を追い出す
--- test_urger_thread_old.cpp 2012-03-08 11:42:42.570478359 +0900
+++ test_urger_thread.cpp 2012-03-08 11:43:04.921728796 +0900
@@ -1,6 +1,5 @@
#include <iostream>
#include <string>
-#include <boost/ref.hpp>
#include <boost/thread.hpp>
using namespace std;
@@ -15,7 +14,7 @@
urger() : end_flag(false) {}
// スレッドのメインルーチン
- void operator()()
+ void u_main()
{
// 基本的に無限ループしておく
for(;;)
@@ -51,7 +50,7 @@
// 催促スレッド起動
urger u;
- boost::thread thr( boost::ref(u) );
+ boost::thread thr( &urger::u_main, &u );
// 入力待ち
cout << "何か書いてね: ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment