Thread: Ideas for the upcoming C++0x

  1. #1

    Join Date
    Apr 2008
    Location
    USA
    Posts
    76

    The upcoming C++0x standard

    The upcoming standard for C++, C++0x, will introduce some interesting new features to C++. I've created a file demonstrating some of my own personal ideas for new features (some of which are already believed to be used in the new standard).

    Click here to take a look at the example code.

    Remember, almost all of it is just my (probably silly) thoughts, and won't actually be in the new standard.

    Discuss.

    EDIT:
    This is not for real suggestions or anything, just thoughts.
    Last edited by rudyman; 04-21-2008 at 05:45 PM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    1) The C++0x standard is in its finalization stage. It's a bit late for new feature ideas.
    2) Concepts, initializer lists and lambdas are all part of the next standard. Here's an idea of how your example would look there:
    Code:
    #include <iostream>
    
    // This is actually defined by the standard library.
    concept Container<typename C>
    {
      // Name various types associated with the container (with defaults).
      typename value_type;
      typename pointer = value_type*;
      typename size_type = std::size_t;
      // ...
      typename iterator;
      // A container's iterator must at least model ForwardIterator.
      where ForwardIterator<iterator>;
    
      // Some members are required.
      size_type C::size() const;
      iterator C::begin();
      iterator C::end();
    
      // and so on ...
    };
    
    template <class T>
    class vector
    {
        public:
            typedef T value_type;
            // ...
    
            // Initializer lists aren't finalized yet - no idea how they'll look.
            vector(initializer_list<T> init_list)
            {
                for(int i = 0; i < init_list.length(); i++) // *5
                {
                    T curr = init_list[i];
                    push_back(curr);
                }
            }
    
             size_type size() { return m_end - m_start; }
             // ...
    };
    // Tell the compiler that every vector is a Container.
    template <typename T>
    concept_map<Container<vector<T>>>
    {
      // It should all just fit.
    }
    
    template <Container C, UnaryFunction Fn>
      requires Convertible<C::value_type, Fn::argument_type>,
    Fn for_each(const C& arry, Fn func)
    {
        // Oh yeah, foreach loops are supported.
        for(T &t : arry) {
            func(t);
        }
    }
    
    int main()
    {
        vector<int> nums = {2, 7, 1, 3, 4, 8};
    
        for_each(nums, [] (v) { cout << v << endl; });
    
        // The type of "[] (v) { cout << v << endl; }" is unspecified, but it fulfills the UnaryFunction
        // concept and is thus callable.
    }
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    So ... is MinGW going to be updated? Is VC++?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by guesst View Post
    So ... is MinGW going to be updated? Is VC++?
    Considering that even mainstream compilers still don't offer complete (or at least, completely correct) support for the CURRENT standard, I would wager that full support for C++0x is at least a decade away.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by guesst View Post
    So ... is MinGW going to be updated? Is VC++?
    Of course. But as Brewbuck says, it's going to take some time before we see the any of the bigger changes [some of the current compiler extensions that for example gcc and VC have are being standardized in the standard, so that will require something from no to very little work to make those features standard compliant], and it may not be complete for MANY years yet. That is, once the standard has be approved - that's yet to happen too...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Some compilers are starting to support TR1, however. It's a start at least.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    With respect to those of us in our field who take the time to write the software we use to compile our code; programming languages are like a democracy, everyone is always quick to jump in with complaints and opinions. Hell, even solutions are offered, but ultimately the fact remains, no one ultimately can agree 100&#37; with everyone. I think that is the particular reason why C++ compilers are lagging behind.

    Not to mention one simple fact about the software industry that transcends the opinions and complaints of you and me, there will always be rogue companies such as Microsoft releasing compilers that adhere to some areas of the standard, and leaving other areas entirely up to what they think is best. In short, there is far too much chaos for a fully compliant compiler ever to get finished. Especially when software engineers take a liking to non-standard features that their compiler supports.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Work is underway already to support the new standard. Of course, it will still take a long time. But some features are supported.

    For example: one compiler has been supporting r-value references for a long time. The standard proposal was mostly based on that feature.
    GCC 4.3 (released) has experimental support for quite a few features, like r-value references and variadic templates. GCC 4.4 will have support for more, and GCC 4.5 for yet more.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Project ideas.
    By Wraithan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 04-25-2009, 03:29 PM
  2. Ideas, how do you get them? xD
    By Akkernight in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 01-22-2009, 03:53 AM
  3. cool ideas for a game
    By Shadow12345 in forum Game Programming
    Replies: 7
    Last Post: 05-18-2004, 08:37 PM
  4. idea's idea's idea's
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 04-29-2002, 12:30 AM
  5. Small app ideas
    By dirkduck in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 02-15-2002, 08:57 PM