Simple use of the Boost library-processing of time and date (1), boost Library
Processing of time and date is always a complicated problem, while processing of time and date in C ++ is also relatively simple, unlike Java and C #, the stream provides a class that is very convenient and easy to use. However, with the launch of Boost, time processing has become more and more simple and convenient. Today we will learn some convenient processing methods:
First, let's take a look at a basic class for time processing in Boost, which is also the base class of several subsequent classes-timer. timer class can measure the passage of time. Based on different platforms, it provides time control in milliseconds or even microseconds. We can also use it to make a very simple timer. below, we use code to explain the usage of timer:
#include <iostream>#include <boost/timer.hpp>int main() { boost::timer t; std::cout << "Max timespan : " << t.elapsed_max() / 3600 << "h" << std::endl; std::cout << "Min timespan : " << t.elapsed_min() << "s" << std::endl; std::cout << "Time elapsed : " << t.elapsed() << std::endl; return 0;}
Generally, we only need to use the above three timer class member methods. The function names also probably know their usefulness. They are: getting the maximum measurable time span, the Unit is hours. The minimum time span that can be measured is measured in seconds. It should be noted that the starting time of the elapsed time is when the timer instance is constructed, not when the program starts to run!
Timer class is more than enough for short-term processing, because its maximum time span is several hundred hours, that is, we should use it to test the running time of some algorithms. If the processing time is in the unit of day, month, and year, you cannot continue to use the timer class. Let's talk about the specific usage!
BOOST library usage Problems
Copy all the compiled. lib files to vs2010.
For example
C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ include \ has a boost folder, which contains useful header Files
C: \ Program Files \ Microsoft Visual Studio 10.0 \ VC \ lib has your. lib File
Otherwise, the vc cannot find the include and link paths.
That's what I did ......
How long does it take to learn the Boost library?
Select a topic every day for 1-2 hours. You can finish learning the main content in about one month.