随笔分类 - 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...
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:int seed = 1;int rand() { return ( (seed = seed *214013 + 2531011) >> 16 ) & 32767;}
阅读全文
摘要:#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
阅读全文
摘要:// 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);.
阅读全文
摘要:http://en.wikipedia.org/wiki/C%2B%2B11#Explicit_overrides_and_final
阅读全文

浙公网安备 33010602011771号