DDD888 发表于 24-6-2016 09:27:15

c++ question template<class ...Args>

https://github.com/facebook/folly/blob/master/folly/ProducerConsumerQueue.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_) T(std::forward<Args>(recordArgs)...);
      writeIndex_.store(nextRecord, std::memory_order_release);
      return true;
    }

    // queue is full
    return false;
}

TIA

艾瑞克 发表于 24-6-2016 10:51:07

http://www.cplusplus.com/articles/EhvU7k9E/

it's a new feature of C++ 11

DDD888 发表于 24-6-2016 11:17:34

艾瑞克 发表于 24-6-2016 10:51
http://www.cplusplus.com/articles/EhvU7k9E/

it's a new feature of C++ 11

Thanks:good

clarkli 发表于 24-6-2016 21:05:51

Vairadic template
页: [1]
查看完整版本: c++ question template<class ...Args>