本文整理汇总了C++中std::initializer_list::size方法的典型用法代码示例。如果您正苦于以下问题:C++ initializer_list::size方法的具体用法?C++ initializer_list::size怎么用?C++ initializer_list::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::initializer_list
的用法示例。
在下文中一共展示了initializer_list::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromColors
CachedPalette CachedPalette::fromColors(std::initializer_list<Color>v) {
CachedPalette pal(v.size());
auto it = v.begin();
for (int i = 0; i < pal.levels(); i++)
pal[i] = *(it++);
return pal;
}
示例2: test
void test ( const std::initializer_list<T> &vals ) {
typedef std::dynarray<T> dynA;
dynA d1 ( vals );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
}
示例3: nr
Matrix::Matrix(std::initializer_list<double> v) : nr(v.size()), nc(1) {
data = new double [nr];
int i = 0;
for (double d : v)
data[i++] = d;
}
示例4: setHeader
bool setHeader(std::initializer_list<std::string> list) {
if (list.size() != Columns) {
return false;
}
header.insert(header.begin(), list);
return true;
}
示例5: comb
double comb(std::initializer_list<double> values) {
double sum = 0.0;
for (double value: values) {
sum += value;
}
return (sum/values.size());
}
示例6:
void IGraphicObject::mFunction_AddVertices2D(NOISE_GRAPHIC_OBJECT_TYPE buffType, std::initializer_list<NVECTOR2> vertexList, std::initializer_list<NVECTOR4> colorList, std::initializer_list<NVECTOR2> texcoordList)
{
N_SimpleVertex tmpVertex;
auto vertexIter = vertexList.begin();
auto colorIter = colorList.begin();
auto texcoordIter = texcoordList.begin();
//construct a N_SimpleVertex
for (UINT i = 0;i < vertexList.size();i++)
{
tmpVertex =
{
NVECTOR3(vertexIter->x+m_pBaseScreenSpacePosOffset->x,vertexIter->y + m_pBaseScreenSpacePosOffset->y,0.0f),
*colorIter++,
*texcoordIter++
};
vertexIter++;
m_pVB_Mem[buffType]->push_back(tmpVertex);
}
//now it is allowed to update because of modification
mCanUpdateToGpu[buffType] = TRUE;
}
示例7: qDebug
ProtocolDescriptorTestNode::ProtocolDescriptorTestNode(QString name, std::initializer_list<ProtocolDescriptorTestNode> init) {
qDebug() << "*** CONSTRUCTOR CALLED - 2 *** ";
qDebug() << init.size();
for(ProtocolDescriptorTestNode x : init) {
qDebug() << x.name << x.id;
}
}
示例8: map
Set<T>::Set(std::initializer_list<T> args) : map()
{
reserve(args.size());
for (const auto &elm : args) {
insert(elm);
}
}
示例9: count
UIntVector::UIntVector(const std::initializer_list<unsigned int>& list) : count(list.size()), max_size(1 << static_cast<int>(ceil(log2(count)))), data(new unsigned int[max_size]) {
size_t i;
std::initializer_list<unsigned int>::iterator item;
for(i = 0, item = list.begin(); item != list.end(); ++i, ++item) {
data[i] = *item;
}
}
示例10: malloc
// Constructor with initializer list
DNA::DNA(const std::initializer_list<unsigned char> inputList) {
dataSize = inputList.size();
// Initialize genes
dataGenes = (unsigned char*) malloc(dataSize * sizeof(unsigned char));
std::memcpy(dataGenes, inputList.begin(), dataSize);
}
示例11: format
std::string format(const char* fmt, std::initializer_list<Printable> values)
{
std::stringstream ss;
while (*fmt) {
auto next = strchr(fmt, '%');
// emit the rest of the format string if there are no more percents
if (!next) {
ss << fmt;
break;
}
// emit everything up to the next percent
ss.write(fmt, next - fmt);
++next;
REALM_ASSERT(*next);
// %% produces a single escaped %
if (*next == '%') {
ss << '%';
fmt = next + 1;
continue;
}
REALM_ASSERT(isdigit(*next));
// The const_cast is safe because stroul does not actually modify
// the pointed-to string, but it lacks a const overload
auto index = strtoul(next, const_cast<char**>(&fmt), 10) - 1;
REALM_ASSERT(index < values.size());
(values.begin() + index)->print(ss);
}
return ss.str();
}
示例12: runtime_error
std::shared_ptr<cainteoir::buffer> zip_archive::read(const char *aFilename) const
{
std::string filename = aFilename;
auto entry = data.find(filename);
if (entry == data.end())
{
size_t pos = 0;
while ((pos = filename.find("%20", pos)) != std::string::npos)
{
filename.replace(pos, 3, " ");
++pos;
}
entry = data.find(filename);
}
if (entry == data.end())
return std::shared_ptr<cainteoir::buffer>();
const zip_data &item = entry->second;
if (item.cached) return item.cached;
auto decoder = *(zip_compression.begin() + item.compression_type);
if (item.compression_type >= zip_compression.size() || decoder == nullptr)
throw std::runtime_error(i18n("decompression failed (unsupported compression type)"));
cainteoir::buffer compressed { item.begin, item.begin + item.compressed };
return const_cast<zip_data &>(item).cached = decoder(compressed, item.uncompressed);
}
示例13:
// Set with initializer list
Set(const std::initializer_list<value_type>& l) {
_set.reserve(l.size());
for (const auto& value : l) {
insert(value);
}
}
示例14: Node
BinTree::BinTree(std::initializer_list<int> inlist)
{
if (inlist.size()==0) return;
root = new Node(*inlist.begin());
for (auto& el : inlist)
insert(el);
}
示例15: array
Vector<T>::Vector(const std::initializer_list<T> args) : size_array(args.size()), cap_array(args.size()*2), array(new T[cap_array]) {
int i = 0;
for (auto iter = args.begin(); iter != args.end(); ++iter) {
array[i] = *iter;
++i;
}
}