0
我怎么能初始化原子变量到结构,提高::原子MAX我怎么能初始化的boost ::原子变量
我想:
#include <boost/atomic.hpp>
struct mem {
// error: conversion from ‘int’ to non-scalar type ‘boost::atomics::atomic<int>’ requested
boost::atomic<int> MAX = 100;
// error: expected identifier before numeric constant
boost::atomic<int> MAX(100);
// error: ‘boost::atomics::atomic<T>::atomic(const boost::atomics::atomic<T>&) [with T = int]’ is private
boost::atomic<int> MAX = (boost::atomic<int>) 100;
// warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
boost::atomic<int> MAX{100};
}
注:我可以不使用C + +11或C++ 14。
你需要在构造函数中初始化它们 – Danh