C++0x

closed account (zb0S216C)
Do this need to be downloaded? or is it built into the compiler.
Built into the compiler. (Once they implement it though).
Do this need to be downloaded?
No.
or is it built into the compiler.
Not yet. :)

Regards

gcc already supports part of the features planned for the new C++ standard (C++0x, x is the unknown year, now in hexadecimal)

PS: I heard MS VS also has support for most of the planned features. May be even more so than gcc.
Last edited on
Is this already built-in to the current version of GCC? If so, what libraries are in there? Are they enabled by default or do I need to flip on some compiler/linker setting?
closed account (3hM2Nwbp)
I'm not sure about GCC, but VS2010 comes stock with lambdas, smart pointers, the auto keyword, the decltype keyword, and Variadic Templates if I recall.
Kyon wrote:
Is this already built-in to the current version of GCC? If so, what libraries are in there? Are they enabled by default or do I need to flip on some compiler/linker setting?
You have to enable it with the option "-std=c++0x". Look here: http://gcc.gnu.org/projects/cxx0x.html

Luc Lieber wrote:
I'm not sure about GCC, but VS2010 comes stock with lambdas, smart pointers, the auto keyword, the decltype keyword, and Variadic Templates if I recall.
Probably. I think that VS will implement the entire standard first. They have a lot of well financed dedicated manpower. Not that implementing the future standard is priority at that point, but people are eager to experiment.

On the other hand, I am afraid that C++0x will meet with the same destiny as C99. Limited adoption in toolchains for smaller markets. Also, the language starts to leave its Pascal-like (ALGOL-like) clarity and starts to become a bit like Perl. (I criticize only its readability.) In fact, I frequently come here http://shootout.alioth.debian.org/ to look at various language sources. I mainly try to assess how much strain is necessary to comprehend the overall structure of a program in a given language. It is subjective, but Python seems to be my personal winner, but is so slow. C++ is not the worst, but is much messier than C. Functional languages vary. Actually, even Perl is very readable for some problems.

I mean, I understand that the use of punctuation helps emphasize some aspects of the code. For example, Scheme and Lisp have limited means for punctuation (primarily parenthesis), and you can loose yourself easily in larger bodies of code. Even with intelligent editor, you have to stay very focused (not on your thoughts). However, I feel that C++ starts to overdo it with the use of symbols and symbol sequences for special purposes. I think that the approach should have been more unified and stick closer to C to begin with. Instead of inheritance of structures, they should have introduced delegation of interfaces to sub-objects or something like that, which is still needed in the language. Also, all this implicit/default behavior is destructive. This is one of the few languages where almost anything you don't know will certainly kill you. It is good to have automatic option for something, but you should always request it. Now, partly because of backward compatibility to C, everything is so silently deadly.

Regards

EDIT: I mean, why didn't they allow the interoperability with C to be a linker problem (like the .NET approach) and create a clean language. It is moot point now. C++ is my personal favorite despite everything and that's why it hurts me to see how doomed its architecture and design essentially are.
Last edited on
Actually GCC is the compiler with most C++0x support ( http://wiki.apache.org/stdcxx/C++0xCompilerSupport )
g++ 4.6 has almost complete C++0x support ( missing only the multi-threading part and some other minor things )
Bazzy wrote:
Actually GCC is the compiler with most C++0x support ( http://wiki.apache.org/stdcxx/C++0xCompilerSupport )
g++ 4.6 has almost complete C++0x support ( missing only the multi-threading part and some other minor things )
I'm glad if that is so. But still, this list appears less exhaustive/detailed from the list at the gcc's site.
closed account (iw0XoG1T)
Because one of the text books I keep on my shelf pushed both <array> and <regex> I downloaded boost and started to use them. I must say I really can't see any advantage to <array>. I have used the auto and it is quite pleasant. But when I tried <regex> I ran into all types of problems so much so that I am still using the boost version. Where do you find documentation and examples of these new features when you run into problems?

Note: I have only experimented with the gcc compiler.
Last edited on
You should check Gcc documentation and C++0x drafts.
Also boost documentation itself should be useful.
closed account (iw0XoG1T)
Boost documentation is great in fact I have used it to understand these new features. But I was not able to get the same test programs to run using <regex> as I was with the Boost headers and library. It would not bother me but I have this fear that I am doing something stupid--and it is not a bug with the compiler( I would be willing to bet it is me and not the complier).

this is a very simple boost example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
    std::string line;
    boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

    while (std::cin)
    {
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;
    }
}

Can anyone show me how to make this same program run using the C++0x standard?

edit: here is the source for the above example: http://www.boost.org/doc/libs/1_45_0/more/getting_started/unix-variants.html
Last edited on
closed account (iw0XoG1T)
just for the record this is what I tried:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <regex>
#include <iostream>
#include <string>

int main()
{
    std::string line;
    std::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

    while (std::cin)
    {
        std::getline(std::cin, line);
        std::smatch matches;
        if (std::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;
    }
}


g++ -g -Wall -pedantic -MMD -MP -std=c++0x -c test.cpp -o obj/test.o
g++ obj/test.o -o main_test


It does make an object file but it won't link.
edit: I am beginning to think it has not been implemented yet; but why would they provide headers for something that does not work?
Last edited on
You need both compiler and C++ standard library support for C++0x. GNU splits those two out. The GNU C++ standard library is a little further behind on implementing certain features it seems.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x
PanGalactic wrote:
The GNU C++ standard library is a little further behind on implementing certain features it seems.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x

It is still amazing how many features the guys have managed to implement. I can only imagine how many people are actively contributing. And this is compiler and language development! Not something I'd do in my lunch break.

(Also, I heard that the gcc's code is a bit messy on the internals. Complex too.)
simeonz wrote:
It is still amazing how many features the guys have managed to implement.


No doubt. Even more amazing when you consider how close to a full C++0x implementation you get with GCC and Boost combined (namespace issues excepted).

I'm very tempted to default our continuous integration builds to "-std=c++0x" soon to see what breaks.
Topic archived. No new replies allowed.