initializer_list

initializer_list

Sorry for multiple post - the forum said initially it would not accept and when I submitted a second time posted it twice

 

 It is stated that there is support for General Initializer Lists with version 13. However, I am unable to

#include <initializer_list>

 

to be able to use initializer lists

 

is there any workaround?

7 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Intel does not provide its own set of header/libraries so if you can't #include then it's probably because you're using an older verion of GNU (pre version 4.4) that doesn't yet have support for this C++11 header.

Or if you're on the Windows platform then Microsoft does not yet have this
header in any release.

The real question is once you include the initializer_list header will they actually work, i.e. will the 13.0 Intel C++ compiler (when using the c++11 option) actually match on the intializer_list constructor in the standard library containers if you use the -std=c++0x or -std=c++11 option.

For example:

#include
#include

int main() {
std::vector v( { 1, 2} ); // does this call the vector initalizer constructor?
return 0;
}

Unfortunately the answer is no since the Intel C++ compiler does not currently support C++11 extended initalizer lists.

General initializer lists are only partially supported in 13.0 as documented here:
http://software.intel.com/en-us/articles/c0x-features-supported-by-intel...

You'll see it says "Partial" under General initializer lists.

Judy

As far as a workaround, c++11 initializer lists should never be necessary, you can always do the aggregate initialization an element at a time or in the case of C++ standard library containers you can do an aggregate initalization into an array and then initialize the constructor with an iterator that points to the beginning and end of the array.

Judy

>>...Or if you're on the Windows platform then Microsoft does not yet have this header in any release...

Microsoft VS 2010 Express edition has it ( actually since 30/09/2009 ). The header has one dependency on 'cstddef' header file. I can upload 'initializer_list' if you need it and please let me know.

Note: 'cstddef' is included with all VS 20xx.

'initializer_list' enclosed. Note: txt extension was added and you will need to rename the file.

Anlagen: 

AnhangGröße
Herunterladen initializer-list.txt1.68 KB

>>...
>>std::vector v( { 1, 2} ); // does this call the vector initalizer constructor?
>>...

No. Please take a look at example with 'initializer_list' class at:
.
http://en.cppreference.com/w/cpp/utility/initializer_list

>>>>...Or if you're on the Windows platform then Microsoft does not yet have this header in any release...
>>
>>Microsoft VS 2010 Express edition has it ( actually since 30/09/2009 ).

I've done a test and I used an example from:
.
http://en.cppreference.com/w/cpp/utility/initializer_list

and 'initializer_list' header from VS 2010 can not be used with VS 2005 or VS 2008.


#include "iostream"

#include "vector"

#include "C:VS.2010VCIncludeinitializer_list"

...

S< int > s = { 1, 2, 3, 4, 5 };				// Compilation error with VS 2005 & VS 2008

s.append( { 6, 7, 8 } );					// Compilation error with VS 2005 & VS 2008

...

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen