473,516 Members | 3,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

initializer_list in the new standard

In the new standard of C++ (C++ 0x), it has a new template class which
can contain a sequence of data.
there are many other templates like vector,dequeue and list are there.
How this one differs. can't we existing containers than this one?

Mar 1 '07 #1
9 4320
Sarath wrote:
In the new standard of C++ (C++ 0x), it has a new template class which
can contain a sequence of data.
there are many other templates like vector,dequeue and list are there.
How this one differs. can't we existing containers than this one?
Are you referring to std::array? The difference is that array is an
aggregate type, so all of its members are held directly in the object,
just as with a C-style array. This means, for example, that when you
create an array object on the stack, all of its members are also on the
stack.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Mar 1 '07 #2
On Mar 1, 9:32 pm, Pete Becker <p...@versatilecoding.comwrote:
Sarath wrote:
In the new standard of C++ (C++ 0x), it has a new template class which
can contain a sequence of data.
there are many other templates like vector,dequeue and list are there.
How this one differs. can't we existing containers than this one?

Are you referring to std::array? The difference is that array is an
aggregate type, so all of its members are held directly in the object,
just as with a C-style array. This means, for example, that when you
create an array object on the stack, all of its members are also on the
stack.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
no I was talking about the intrinsic type arrays

Mar 1 '07 #3
Sarath wrote:
On Mar 1, 9:32 pm, Pete Becker <p...@versatilecoding.comwrote:
>Sarath wrote:
>>In the new standard of C++ (C++ 0x), it has a new template class which
can contain a sequence of data.
there are many other templates like vector,dequeue and list are there.
How this one differs. can't we existing containers than this one?
Are you referring to std::array? The difference is that array is an
aggregate type, so all of its members are held directly in the object,
just as with a C-style array. This means, for example, that when you
create an array object on the stack, all of its members are also on the
stack.

no I was talking about the intrinsic type arrays
Sorry, I don't know what you're referring to. The current C++ draft
doesn't use the word "intrinsic" anywhere, and I'm not going to look at
every use of the word "array" to see if it might fit this. <g>

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Mar 1 '07 #4
On 1 Mar 2007 04:36:10 -0800 in comp.lang.c++, "Sarath"
<CS*****@gmail.comwrote,
>no I was talking about the intrinsic type arrays
What section number in the draft are you referring to?

Mar 1 '07 #5
On Mar 2, 2:17 am, David Harmon <sou...@netcom.comwrote:
On 1 Mar 2007 04:36:10 -0800 in comp.lang.c++, "Sarath"
<CSar...@gmail.comwrote,
no I was talking about the intrinsic type arrays

What section number in the draft are you referring to?
Could you please refer to this link?

http://en.wikipedia.org/wiki/C%2B%2B...e_constructors

Mar 2 '07 #6
On Mar 2, 6:35 am, "Sarath" <CSar...@gmail.comwrote:
On Mar 2, 2:17 am, David Harmon <sou...@netcom.comwrote:
On 1 Mar 2007 04:36:10 -0800 in comp.lang.c++, "Sarath"
<CSar...@gmail.comwrote,
>no I was talking about the intrinsic type arrays
What section number in the draft are you referring to?

Could you please refer to this link?

http://en.wikipedia.org/wiki/C%2B%2B...e_constructors
The goal of this class is not to act as a container such as vector or
dequeue, instead it is meant to be used when initializing, for
example, such a container. The idea is that you should be able to
write code such as:

std::vector<inta = {1, 2, 3, 4};

Instead of

std::vector<inta;
a.push_back(1);
a.push_back(2);
// and so on

--
Erik Wikström

Mar 2 '07 #7
Sarath wrote:
On Mar 2, 2:17 am, David Harmon <sou...@netcom.comwrote:
>On 1 Mar 2007 04:36:10 -0800 in comp.lang.c++, "Sarath"
<CSar...@gmail.comwrote,
>>no I was talking about the intrinsic type arrays
What section number in the draft are you referring to?

Could you please refer to this link?

http://en.wikipedia.org/wiki/C%2B%2B...e_constructors
You have to be a little careful with that article. As it says at the
top, it's not up to date.

For the latest status of language additions, see
http://www.open-std.org/jtc1/sc22/wg...2006/n2122.htm. In
particular, search for "Initializer Lists", where you'll find a list of
the current papers on this subject.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Mar 2 '07 #8
On Fri, 02 Mar 2007 11:51:52 -0500 in comp.lang.c++, Pete Becker
<pe**@versatilecoding.comwrote,
>For the latest status of language additions, see
http://www.open-std.org/jtc1/sc22/wg...2006/n2122.htm. In
particular, search for "Initializer Lists", where you'll find a list of
the current papers on this subject.
That "initializer list" proposal looked to me as if std::array in the
current draft might serve the same purpose. Is that true, or are the
distinct things?

Mar 3 '07 #9
David Harmon wrote:
On Fri, 02 Mar 2007 11:51:52 -0500 in comp.lang.c++, Pete Becker
<pe**@versatilecoding.comwrote,
>For the latest status of language additions, see
http://www.open-std.org/jtc1/sc22/wg...2006/n2122.htm. In
particular, search for "Initializer Lists", where you'll find a list of
the current papers on this subject.

That "initializer list" proposal looked to me as if std::array in the
current draft might serve the same purpose. Is that true, or are the
distinct things?
In n2100, an initializer_list<Tobject holds either a pair of pointers
or a pointer and a count. So, unlike std::array<T>, it provides indirect
access to a range. The name is also a magic cookie to the compiler,
which generates different code than it would for an ordinary argument.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Mar 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
3758
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.) dicts mapping nodes to neighbor-sets, but if one wants a graph that's implemented in some other way, this may not be the most convenient (or...
52
9572
by: piaseckiac | last post by:
I am producing a website on air and need a link to change the entire website from standard to metric for temperature, pressure, miles-kilometers, and volume. Thank you.
6
8263
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly we get an interest payment. Unless the bank is cruel to its developers the interest figure will be able to be exactly represented by a computer,...
1
2152
by: Corrie Meyer | last post by:
Announcement: SwiftReports standard edition 1.0 for Visual Studio ..NET 2003 released by UniSwift. We are pleased to announce the first release of a fully-managed reporting tool for the Microsoft .NET framework. SwiftReports provides complete code integration with the Visual Studio .NET 2003 environment. Developers can use Visual Studio...
43
4914
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own libraries. I'm not sure if that's a good thing or not. AFAIK, most of Qt is compatable with the Standard Library. That is, QLT can interoperate with...
52
3697
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low level machine. C stands for portability and platform and machine independent. If the C compiler and C standard library are written in C itself, is...
132
4498
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C community. It would seem that C99 is the most up-to-date Standard, but far more people seem to be working off the C89 Standard. Could someone...
1
3193
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: warning: MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5 file /etc/my.cnf from install of...
270
9222
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting to see that the answers to that message prove that programming exclusively in standard C is completely impossible even for a small and ridiculously...
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.