随笔分类 -  C++

摘要:#include #include #include #include #include typedef boost::function ThreadFunc;void InvokeBackgroundThread(ThreadFunc f) { while(true) { try { boost::this_thread::interruption_point(); f(); } catch(boost::thread_interrupted const&) { std::cout thre... 阅读全文
posted @ 2013-11-05 14:47 LambdaTea 阅读(500) 评论(0) 推荐(0)
摘要:0. C++11 compiler support shootouthttp://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx1. Important Minor Syntax Cleanups//Spaces in Template Expressionsstd::vector>;//nullptr and std::nullptr_tf(0); //calls f 阅读全文
posted @ 2013-10-19 16:18 LambdaTea 阅读(400) 评论(0) 推荐(0)
摘要:using namespace std;templatesplit(const T & str, const T & delimiters, vector& result) { vector v; T::size_type start = 0; auto pos = str.find(delimiters, start); while(pos != T::npos) { if(pos != start) // ignore empty tokens v.emplace_back(str, start, pos - start); start = pos + delimi 阅读全文
posted @ 2013-07-02 13:23 LambdaTea 阅读(469) 评论(0) 推荐(0)
摘要:int seed = 1;int rand() { return ( (seed = seed *214013 + 2531011) >> 16 ) & 32767;} 阅读全文
posted @ 2013-01-13 11:44 LambdaTea 阅读(135) 评论(0) 推荐(0)
摘要:#include <iostream>#include <vector>#include <algorithm>#include <boost/bind.hpp>class PrintInt {public: void Print(int i);};void PrintInt::Print(int i) { std::cout << i << std::endl;}int main(int argc, char* argv[]) { std::vector<int> vecs; for(int i = 0; i 阅读全文
posted @ 2012-10-30 11:31 LambdaTea 阅读(500) 评论(0) 推荐(0)
摘要:// for_each. Apply a function to every element of a range.template <class _InputIter, class _Function>_Function for_each(_InputIter __first, _InputIter __last, _Function __f) { __STL_REQUIRES(_InputIter, _InputIterator); for ( ; __first != __last; ++__first) __f(*__first); return __f;}__f(T);. 阅读全文
posted @ 2012-09-04 10:39 LambdaTea 阅读(708) 评论(0) 推荐(0)
摘要:http://en.wikipedia.org/wiki/C%2B%2B11#Explicit_overrides_and_final 阅读全文
posted @ 2012-08-31 10:53 LambdaTea 阅读(140) 评论(0) 推荐(0)