Welcome, Guest. Please login or register. Did you miss your activation email?

Poll

Do you use C++11 features?

Yes
36 (50%)
No, but I plan to use them in the near future
25 (34.7%)
No, and I am not interested in them
11 (15.3%)

Total Members Voted: 71

Voting closed: March 10, 2012, 01:58:16 pm

Author Topic: Do you use C++11?  (Read 21353 times)

0 Members and 2 Guests are viewing this topic.

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Do you use C++11?
« Reply #15 on: March 11, 2012, 11:12:16 am »
Quote from: "Lee R"
Not quite. They can be emulated with preprocessor macros (and they are, at least in Boost.Function).


I think the actual implementation uses variadic macros but I thought it wrapped them inside a huge set of template specialisations (generated by script) to hide them from the end user since they look silly ugly compared to the very clean implementation variadic templates give you. Macros are the last resort of last resorts in C++ so not having to use them is sweet :)
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Do you use C++11?
« Reply #16 on: March 11, 2012, 11:49:54 am »
Quote from: "MorleyDev"
I think the actual implementation uses variadic macros [...]

No, it recursively includes itself. Besides, variadic macros are in fact preprocessor macros, so I'm not sure why you felt the need to mention them. ;)

Quote from: "MorleyDev"
[...]I thought it wrapped them inside a huge set of template specialisations (generated by script)[...]

That description is somewhat inside out. The macros are used to stamp out the overloads.

The nice macro-free headers you see are generated by the preprocessor (using the Boost.Wave preprocessor, I believe). They are then included to improve compile times (i.e. it has nothing to do with how ugly macros are). In fact, if you redefine the maximum overload arity to some value greater than what is provided by the preprocessed headers (or otherwise disable them), the overloads will be generated on-the-fly (no need for scripts at all).

VPellen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Do you use C++11?
« Reply #17 on: March 11, 2012, 11:56:10 am »
Up until ten minutes ago, I'd been feeling kind of lukewarm towards C++11. I'd been curious, and I expected to take it up sooner or later, but nothing really forced my hand.

Ten minutes ago, I learned that C++11 supports member initialization in the class declaration, ie:

Code: [Select]
class C
{
    public:
        int x = 10;
};


I'm turning that compiler flag on, and I'm never going back.

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Do you use C++11?
« Reply #18 on: March 11, 2012, 12:07:40 pm »
huh, interesting. I though the implementation basically did

template<typename T> struct function { };
template<typename R, typename A, typename B> struct function<R (A,B)> : real_function<R, TYPELIST(A,B)>
template<typename R, typename A, typename B,typename C> struct function<R (A,B,C)> : real_function<R, TYPELIST(A,B,C)>
template<typename R, typename A, typename B,typename C,typename D> struct function<R (A,B,C,D)> : real_function<R, TYPELIST(A,B,C,D)>
...

and so-on in that matter for a silly number of implementations. Maybe I'm thinking of Loki or something else but this is definitely a way it can be simulated...

Either way, my point that it's all made infinitely simpler and cleaner looking by variadic templates remains :P
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Do you use C++11?
« Reply #19 on: March 11, 2012, 12:09:14 pm »
Quote from: "MorleyDev"
Either way, my point that it's all made infinitely simpler and cleaner looking by variadic templates remains :P

It was never in question. ;)

[EDIT]

I didn't see the last part of the following sentence, I'm guessing you added it later:
Quote from: "MorleyDev"

Maybe I'm thinking of Loki or something else but this is definitely a way it can be simulated...

Not really. The technique you showed has a fixed maximum arity and thus is not variadic, even if the TYPELIST macro is.

[/EDIT]

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Do you use C++11?
« Reply #20 on: March 11, 2012, 10:54:22 pm »
Thanks everyone for the useful links about C++11. I read a lot about it today, and I'm already using it. I jumped on the unordered_map/set, the ranged based for and the "auto" keyword :P

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Do you use C++11?
« Reply #21 on: March 12, 2012, 03:55:40 am »
Quote from: "VPellen"

Ten minutes ago, I learned that C++11 supports member initialization in the class declaration, ie:

Code: [Select]
class C
{
    public:
        int x = 10;
};



 :shock:

 :D

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
Re: Do you use C++11?
« Reply #22 on: March 12, 2012, 11:45:12 am »
I read about C++11 features a while ago and was amazed with it, started using right away. But so far I only use unordered_map/set, forward_list, the memory library, and some features like "enum class" and RValue references. Lambda expressions is something I want to try sometime but I didn't need it yet. I think I used something from the functional lib once too, that's something I definitely have to look better and start using more often.
Pluma - Plug-in Management Framework

Bigz

  • Full Member
  • ***
  • Posts: 154
    • View Profile
    • Bigz.fr
Do you use C++11?
« Reply #23 on: March 12, 2012, 05:30:44 pm »
Does someone already tried to use the std::thread and has some feedback about it ?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Do you use C++11?
« Reply #24 on: March 12, 2012, 06:35:51 pm »
I think std::thread heavily inspired from boost::thread.

Unfortunately, MSVC 2010 doesn't support it (like many other useful C++11 features :(). However the 2011 version should provide threads, mutexes, atomics, futures etc. :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Dalini

  • Newbie
  • *
  • Posts: 43
    • View Profile
Do you use C++11?
« Reply #25 on: March 12, 2012, 11:20:08 pm »
Too bad we'll have to wait at least a year before we can see the major compilers (GCC, Clang, MSVC) support all the features of the C++11 :-(
"Inconsistency imposes mental friction into a developer's work that no IDE can fully remove."

VPellen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Do you use C++11?
« Reply #26 on: March 13, 2012, 11:55:19 am »
I've spent the last few days cramming C++11 stuff into my brain. Very exciting. For those who want to get a better understanding of C++11, the following links have been extremely helpful for me:

http://www2.research.att.com/~bs/C++0xFAQ.html
http://channel9.msdn.com/Events/GoingNative/GoingNative-2012
http://en.cppreference.com/w/cpp
http://code.google.com/p/mingw-builds/

In order, they are:

1) The C++11 FAQ written by Stroustrup himself
2) A recent event regarding C++11, lots of videos, VERY informative, if nothing else watch the keynote by Stroustrup on C++11 style
3) A C++ reference which contains some details on the newer C++11 libraries
4) Links to more up-to-date MinGW builds, for windows developers who aren't so fond of VC++. Look for 4.7, it's precompiled and should basically work as-is.

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
Do you use C++11?
« Reply #27 on: March 13, 2012, 01:49:28 pm »
Something I feel strage is the naming convention on pointers. unique_ptr, shared_ptr, weak_ptr, ok, all using underscore, then we have nullptr.
Pluma - Plug-in Management Framework

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Do you use C++11?
« Reply #28 on: March 13, 2012, 02:08:09 pm »
Quote from: "gsaurus"
Something I feel strage is the naming convention on pointers. unique_ptr, shared_ptr, weak_ptr, ok, all using underscore, then we have nullptr.


That's a constant and not a type.

I think it is even a keyword? Or am I wrong?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Do you use C++11?
« Reply #29 on: March 13, 2012, 02:31:36 pm »
Quote from: "Groogy"
Quote from: "gsaurus"
Something I feel strage is the naming convention on pointers. unique_ptr, shared_ptr, weak_ptr, ok, all using underscore, then we have nullptr.


That's a constant and not a type.

I think it is even a keyword? Or am I wrong?
It's a keyword.
I use the latest build of SFML2

 

anything