本文整理汇总了C++中initializer_list::size方法的典型用法代码示例。如果您正苦于以下问题:C++ initializer_list::size方法的具体用法?C++ initializer_list::size怎么用?C++ initializer_list::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类initializer_list
的用法示例。
在下文中一共展示了initializer_list::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCell
// // //Add cell to the list
void addCell(initializer_list<int_8 > l) {
if (l.size() == 2) {
listCell.emplace_back( shared_ptr<Cell > (new Line(l)) );
// //listCell.emplace_back(shared_ptr<Cell > (new Line(tmp)) );
} else if (l.size() == 3) {
// //listCell.emplace_back(shared_ptr<Cell > (new Tri(tmp)) );
} else if (l.size() == 4) {
listCell.emplace_back( shared_ptr<Cell > (new Quad(l)) );
} else if (l.size() == 8) {
//listCell.emplace_back( shared_ptr<Cell > (new Hexa(tmp)) );
} else {
cout << "Cell type not understood!"<<endl;
exit(1);
}
nCellSize += l.size() + 1;
auto c = *(listCell.rbegin());
c->id = listCell.size()-1;
c->grid = this;
c->assignCelltoNode();
for (auto v: listVar) {
if (v->loc == 0) {
v->data.push_back(0);
v->data.uncompress();
}
}
c->masterx.resize(levelHighBound[0]+1, false);
c->mastery.resize(levelHighBound[1]+1, false);
c->masterz.resize(levelHighBound[2]+1, false);
}
示例2:
UnitCell::UnitCell(
initializer_list<initializer_list<double>> latticeVectors,
bool isOwner
) :
StateSet(isOwner)
{
unsigned int numCoordinates = latticeVectors.begin()->size();
for(unsigned int n = 1; n < latticeVectors.size(); n++){
TBTKAssert(
(latticeVectors.begin()+n)->size() == numCoordinates,
"UnitCell::UnitCell()",
"Incmopatible coordinate dimensions. The first lattice"
<< "vector has " << numCoordinates << " coordinates, "
<< "while lattice vector " << n << " has "
<< (latticeVectors.begin()+n)->size()
<< " coordinates.",
""
);
}
for(unsigned int n = 0; n < latticeVectors.size(); n++){
this->latticeVectors.push_back(vector<double>());
const initializer_list<double> *latticeVector = (latticeVectors.begin() + n);
for(unsigned int c = 0; c < latticeVector->size(); c++)
this->latticeVectors.at(n).push_back(*(latticeVector->begin()+c));
}
}
示例3: Type
Function(const char* name, const char* returns, initializer_list<char*> takes, const char* description) : Type(name) {
this->takes = new char*[takes.size() + 1];
int index = 0;
for (auto i : takes) { this->takes[index++] = i; }
this->takes[takes.size()] = 0;
this->returns = returns;
this->description = description;
}
示例4: invalid_argument
EvenSequenceNum::EvenSequenceNum(initializer_list<double> args)
{
if (args.size() % 2 != 0)
throw invalid_argument(" initializer_list should contain even number of elements!");
mSequence.reserve(args.size());
for (auto value : args) mSequence.push_back(value);
//mSequence.insert(cend(mSequence), cbegin(args), cend(args)); // alternate to the above for loop
}
示例5:
Vector<T>::Vector(const initializer_list<T>& l) {
static_assert(is_move_assignable<T>::value, "Type is not move assignable.");
static_assert(is_move_constructible<T>::value, "Type is not move constructible."); // Can be constructed fr rvalue
vectorsize = l.size();
heap_size = l.size();
array = new T[vectorsize];
for (int i = 0; i < vectorsize; ++i) {
array[i] = l.begin()[i];
}
}
示例6: Polynomial
template<typename T> Polynomial(initializer_list<T> list){
coeffs.resize(list.size());
int i=list.size()-1;
for(T t:list){
coeffs[i]=t;
i--;
}
reduce();
}
示例7: calc_histogram
/**
* @brief calc_back_project : encapsulate calcHist, provide friendly api, all of the parameters meaning are same as
* the calcHist
*/
void calc_histogram(initializer_list<Mat> images, OutputArray output, initializer_list<int> channels,
initializer_list<int> hist_sizes, initializer_list<float[2]> ranges,
InputArray mask, bool uniform, bool accumulate)
{
size_t const sizes = ranges.size();
vector<float const*> d_ranges(sizes);
for(size_t i = 0; i != sizes; ++i){
d_ranges[i] = *(begin(ranges) + i);
}
calcHist(begin(images), images.size(), begin(channels), mask, output,
channels.size(), begin(hist_sizes), &d_ranges[0], uniform ,accumulate);
}
示例8:
StateTreeNode::StateTreeNode(
initializer_list<double> center,
double halfSize,
int maxDepth
) :
numSpacePartitions(pow(2, center.size()))
{
for(unsigned int n = 0; n < center.size(); n++)
this->center.push_back(*(center.begin() + n));
this->halfSize = halfSize;
this->maxDepth = maxDepth;
}
示例9: invalid_argument
PointSequence(initializer_list<double> args)
{
cout << "size : " << args.size() << endl;
if(args.size() % 2 != 0)
{
throw invalid_argument("initializer_list should"
"contain even number of elements.");
}
for(auto iter = args.begin(); iter != args.end(); ++iter)
{
mVecPoints.push_back(*iter);
}
}
示例10: Vector
Vector(initializer_list<_Tp> __li, const _Allocator& __a = _Allocator()) :
alloc(__a), __size(0), __capacity(0) {
buffer = alloc.allocate(__li.size());
for (auto _list : __li)
push_back(_list);
__capacity = __size;
}
示例11: foo
void foo(initializer_list<int> x)
{
//static_assert(x.size()==2, "dd"); // decomment for bestemmie
int arr[x.size()];
arr[0] = 10;
cout << arr[0] << endl;
}
示例12: computeHashes
static const pair<vector<string>, unordered_map<string, int> > computeHashes(initializer_list<const char *> names)
{
pair <vector<string>, unordered_map<string, int> > result;
result.first.reserve(names.size());
for (const char *name : names) {
result.first.emplace_back(name);
}
result.second.reserve(names.size());
for(typeof(names.size()) i = 0; i < names.size(); i++) {
result.second.emplace(result.first[i], i);
}
return result;
}
示例13: end
Model::Model(initializer_list<string> meshNames,
const string& diffuseName,
const string& specularName,
const string& ambientName,
const string& normalName,
float uniformScale,
float translateY,
float rotateY) {
// Load meshes
meshes.resize(meshNames.size());
int i = 0;
for (auto name : meshNames) {
meshes[i].load(name);
i += 1;
}
// Load textures
diffuse.loadImage(diffuseName);
specular.loadImage(specularName);
if (useNormalMapping) {
ambient.loadImage(ambientName);
normal.loadImage(normalName);
// Generate tangent values for normal mapping
transform(begin(meshes), end(meshes), back_inserter(tangents), Model::generateTangents);
}
// Save scaling and translation values
this->uniformScale = uniformScale;
this->translateY = translateY;
this->rotateY = rotateY;
}
示例14: invalid_argument
PointSequence(initializer_list<double> args)
{
if (args.size() % 2 != 0)
throw invalid_argument("initializer_list should contain even number of elements.");
for (auto iter = args.begin(); iter != args.end(); ++iter)
mVecPoints.push_back(*iter);
}
示例15: Vector
Vector(initializer_list<T> list) : size{list.size()}
{
cout << "initializer list constructor" << endl;
int i = 0;
a.reset(new T[size]);
for (auto iter = list.begin(); iter != list.end(); ++iter, ++i)
a.get()[i] = *iter;
}