当前位置: 首页>>代码示例>>C++>>正文


C++ duration_type类代码示例

本文整理汇总了C++中duration_type的典型用法代码示例。如果您正苦于以下问题:C++ duration_type类的具体用法?C++ duration_type怎么用?C++ duration_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了duration_type类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: date_type

 //allow internal access from operators
 date_type operator+(const duration_type& dd) const
 {
   if(dd.is_special())
   {
     return date_type(date_rep_type(days_) + dd.get_rep());
   }
   return date_type(date_rep_type(days_) + static_cast<date_int_type>(dd.days()));
 }
开发者ID:ngzHappy,项目名称:cpc2,代码行数:9,代码来源:date.hpp

示例2: frontBlock

 bool frontBlock(T& t, duration_type timeout) const
 {
     boost::mutex::scoped_lock lock(mutex_);
     bool gotValue = false;
     if (timeout.count() > 0)
     {
         if (deque_.empty())
         {
             available_.wait_for(lock, timeout);
         }
         if (!deque_.empty())
         {
             t = deque_.front();
             gotValue = true;
         }
     }
     else
     {
         while (deque_.empty())
         {
             available_.wait(lock);
         }
         t = deque_.front();
         gotValue = true;
     }
     return gotValue;
 }
开发者ID:ryanpartridge,项目名称:scratchpad,代码行数:27,代码来源:LockingQueue_new.hpp

示例3: put

    OutItrT put(OutItrT next,
                std::ios_base& a_ios,
                char_type fill_char,
                const duration_type& dd) const
    {
      if (dd.is_special()) {
        return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
      }

      typedef std::num_put<CharT, OutItrT> num_put;
      if (std::has_facet<num_put>(a_ios.getloc())) {
        return std::use_facet<num_put>(a_ios.getloc()).put(next, a_ios, fill_char, dd.get_rep().as_number());
      }
      else {
        num_put* f = new num_put();
        std::locale l = std::locale(a_ios.getloc(), f);
        a_ios.imbue(l);
        return f->put(next, a_ios, fill_char, dd.get_rep().as_number());
      }

    }
开发者ID:imos,项目名称:icfpc2015,代码行数:21,代码来源:date_facet.hpp

示例4: bucket_count

  /// Estimate the necessary number of buckets
  std::size_t bucket_count(
      duration_type measurement_period, duration_type sampling_period) {
    if (sampling_period <= duration_type(0)) {
      std::ostringstream os;
      os << "jb::event_rate_estimate - sampling period ("
         << sampling_period.count() << ") must be a positive number";
      throw std::invalid_argument(os.str());
    }
    if (sampling_period > measurement_period) {
      std::ostringstream os;
      os << "jb::event_rate_estimate - measurement period ("
         << measurement_period.count() << ") is smaller than sampling period ("
         << sampling_period.count() << ")";
      throw std::invalid_argument(os.str());
    }

    if ((measurement_period % sampling_period).count() != 0) {
      std::ostringstream os;
      os << "jb::event_rate_estimate - measurement period ("
         << measurement_period.count()
         << ") must be a multiple of the sampling period ("
         << sampling_period.count() << ")";
      throw std::invalid_argument(os.str());
    }

    // ... because measurement_period and sampling_period are positive
    // numbers N will be a positive number ...
    typedef typename duration_type::rep rep;
    typedef typename std::make_unsigned<rep>::type unsigned_rep;
    unsigned_rep N = measurement_period / sampling_period;
    // ... beware, the type may be larger than what can be stored in
    // an std::size_t (weird segmented memory platforms, yuck) ...
    if (N >= std::numeric_limits<std::size_t>::max()) {
      std::ostringstream os;
      os << "jb::event_rate_estimate - measurement period ("
         << measurement_period.count() << ") is too large for sampling period ("
         << sampling_period.count() << ")";
      throw std::invalid_argument(os.str());
    }
    return static_cast<std::size_t>(N);
  }
开发者ID:coryan,项目名称:jaybeams,代码行数:42,代码来源:event_rate_estimator.hpp

示例5: date_type

 //allow internal access from operators
 date_type operator+(const duration_type& dd) const
 {
   return date_type(date_rep_type(days_) + dd.days());
 }
开发者ID:NeoAnomaly,项目名称:xray,代码行数:5,代码来源:date.hpp

示例6:

inline
int_type operator+(int i, duration_type<int_type> dt){
  return i + dt.get_rep();
}
开发者ID:Albermg7,项目名称:boost,代码行数:4,代码来源:testgeneric_period.cpp


注:本文中的duration_type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。