找回密码
 FreeOZ用户注册
查看: 1639|回复: 3
打印 上一主题 下一主题

[学习深造] c++ question template<class ...Args>

[复制链接]
跳转到指定楼层
1#
发表于 24-6-2016 10:27:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
https://github.com/facebook/foll ... ucerConsumerQueue.h

I read the source code and I do not understand
template<class ...Args>
  bool write(Args&&... recordArgs) {

in this function

template<class ...Args>
  bool write(Args&&... recordArgs) {
    auto const currentWrite = writeIndex_.load(std::memory_order_relaxed);
    auto nextRecord = currentWrite + 1;
    if (nextRecord == size_) {
      nextRecord = 0;
    }
    if (nextRecord != readIndex_.load(std::memory_order_acquire)) {
      new (&records_[currentWrite]) T(std::forward<Args>(recordArgs)...);
      writeIndex_.store(nextRecord, std::memory_order_release);
      return true;
    }

    // queue is full
    return false;
  }

TIA
回复  

使用道具 举报

2#
发表于 24-6-2016 11:51:07 | 只看该作者
http://www.cplusplus.com/articles/EhvU7k9E/

it's a new feature of C++ 11
回复  

使用道具 举报

3#
 楼主| 发表于 24-6-2016 12:17:34 | 只看该作者
艾瑞克 发表于 24-6-2016 10:51
http://www.cplusplus.com/articles/EhvU7k9E/

it's a new feature of C++ 11

Thanks
回复  

使用道具 举报

4#
发表于 24-6-2016 22:05:51 | 只看该作者
Vairadic template
回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+11, 28-10-2024 00:17 , Processed in 0.016496 second(s), 18 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表