>
+void* start_routine(void* ptr)
+{
+ P* p = reinterpret_cast(ptr);
+ (p->first->*(p->second))(); // Call member function pointer
+ delete p;
+ return NULL;
+}
+
+class NativeThread {
+
+ pthread_t thread;
+
+public:
+ template>
+ explicit NativeThread(void(T::*fun)(), T* obj) {
+ pthread_attr_t attr_storage, *attr = &attr_storage;
+ pthread_attr_init(attr);
+ pthread_attr_setstacksize(attr, TH_STACK_SIZE);
+ pthread_create(&thread, attr, start_routine, new P(obj, fun));
+ }
+ void join() { pthread_join(thread, NULL); }
+};
+
+#else // Default case: use STL classes
+
+typedef std::thread NativeThread;
+
+#endif
+
+#endif // #ifndef THREAD_WIN32_OSX_H_INCLUDED