1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_DETAIL_DURATION_HPP
12 #define BOOST_COMPUTE_DETAIL_DURATION_HPP
13 
14 #include <boost/config.hpp>
15 
16 #ifndef BOOST_COMPUTE_NO_HDR_CHRONO
17 #include <chrono>
18 #endif
19 
20 #ifndef BOOST_COMPUTE_NO_BOOST_CHRONO
21 #include <boost/chrono/duration.hpp>
22 #endif
23 
24 namespace boost {
25 namespace compute {
26 namespace detail {
27 
28 #ifndef BOOST_COMPUTE_NO_HDR_CHRONO
29 template<class Rep, class Period>
30 inline std::chrono::duration<Rep, Period>
make_duration_from_nanoseconds(std::chrono::duration<Rep,Period>,size_t nanoseconds)31 make_duration_from_nanoseconds(std::chrono::duration<Rep, Period>, size_t nanoseconds)
32 {
33     return std::chrono::duration_cast<std::chrono::duration<Rep, Period> >(
34         std::chrono::nanoseconds(nanoseconds)
35     );
36 }
37 #endif // BOOST_COMPUTE_NO_HDR_CHRONO
38 
39 #ifndef BOOST_COMPUTE_NO_BOOST_CHRONO
40 template<class Rep, class Period>
41 inline boost::chrono::duration<Rep, Period>
make_duration_from_nanoseconds(boost::chrono::duration<Rep,Period>,size_t nanoseconds)42 make_duration_from_nanoseconds(boost::chrono::duration<Rep, Period>, size_t nanoseconds)
43 {
44     return boost::chrono::duration_cast<boost::chrono::duration<Rep, Period> >(
45         boost::chrono::nanoseconds(nanoseconds)
46     );
47 }
48 #endif // BOOST_COMPUTE_NO_BOOST_CHRONO
49 
50 } // end detail namespace
51 } // end compute namespace
52 } // end boost namespace
53 
54 #endif // BOOST_COMPUTE_DETAIL_DURATION_HPP
55