• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
3DModelerMan

Favorite little known or underused C++ features

46 posts in this topic

[quote name='swiftcoder' timestamp='1351027616' post='4993211']
If you really need to do something like this, then an array decays to a pointer. You can always store just the 2-dimensional array and cast back to the single dimension as needed.
[/quote]
I have no idea why it was like that as the code was extremely old and just never touched. I believe it was due to passing to an API but that still doesn't make any sense considering the cast is a NOP so it wouldn't even save anything. Edited by joew
2

Share this post


Link to post
Share on other sites
[quote name='swiftcoder' timestamp='1351029275' post='4993220']
Thus why we now need variable template arguments, to fix the deficiencies previously solved via variadic arguments
[/quote]

I was so looking forward to this feature, only to find out that visual studio 2012 would not be supporting it. I really hope microsoft implements at least the really important features of C++11 soon, they're seriously running behind gcc right now. Edited by Radikalizm
0

Share this post


Link to post
Share on other sites
[quote name='Joe the Objective C Lover' timestamp='1351029517' post='4993225']
[quote name='swiftcoder' timestamp='1351027616' post='4993211']
If you really need to do something like this, then an array decays to a pointer. You can always store just the 2-dimensional array and cast back to the single dimension as needed.
[/quote]
I have no idea why it was like that as the code was extremely old and just never touched. I believe it was due to passing to an API but that still doesn't make any sense considering the cast is a NOP so it wouldn't even save anything.
[/quote]
The most common cases I've seen that in is crappy game tutorials code.

Also, I like your nickname. It's much better...now that I've changed it. Edited by Washu
1

Share this post


Link to post
Share on other sites
[quote name='Washu' timestamp='1351029783' post='4993229']
Also, I like your nickname. It's much better...now that I've changed it.
[/quote]
rofl bah fix it!
0

Share this post


Link to post
Share on other sites
[quote name='Joe the Objective C Lover' timestamp='1351030610' post='4993238']
[quote name='Washu' timestamp='1351029783' post='4993229']
Also, I like your nickname. It's much better...now that I've changed it.
[/quote]
rofl bah fix it!
[/quote]

Personally I liked "joew" seeing as it is the *ultimate* first name plus last initial.
0

Share this post


Link to post
Share on other sites
[quote name='jwezorek' timestamp='1351031130' post='4993239']
[quote name='Joe the Objective C Lover' timestamp='1351030610' post='4993238']
[quote name='Washu' timestamp='1351029783' post='4993229']
Also, I like your nickname. It's much better...now that I've changed it.
[/quote]
rofl bah fix it!
[/quote]

Personally I liked "joew" seeing as it is the *ultimate* first name plus last initial.
[/quote]
Well, I was going to go for [Joe the:Objective c:Lover] but it wouldn't accept that.
0

Share this post


Link to post
Share on other sites
Don't make me whine to Drew! [img]http://public.gamedev.net//public/style_emoticons/default/ph34r.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='The Woynillowicz' timestamp='1351031573' post='4993242']
Don't make me whine to Drew! [img]http://public.gamedev.net//public/style_emoticons/default/ph34r.png[/img]
[/quote]
Your wish has been granted. :D Edited by Washu
0

Share this post


Link to post
Share on other sites
[quote name='Washu' timestamp='1351031686' post='4993245']
Your wish has been granted.
[/quote]
To joew!

EDIT: not funny! Edited by joew aka The Woynillowicz
0

Share this post


Link to post
Share on other sites
[quote name='joew aka The Woynillowicz' timestamp='1351031714' post='4993246']
[quote name='Washu' timestamp='1351031686' post='4993245']
Your wish has been granted.
[/quote]
To joew!
[/quote]

I'm CONFUSED?!?
0

Share this post


Link to post
Share on other sites
[quote name='Washu' timestamp='1351031983' post='4993247']
I'm CONFUSED?!?
[/quote]
So am I.... this change actually introduces a compile error for some wtf reason:

[source lang="cpp"]// Original
Rectangle& operator=(const Rectangle& rhs) : left(rhs.left), bottom(rhs.bottom), right(rhs.right), top(rhs.top) {}

// Replaced with
Rectangle& operator=(const Rectangle&) = default;
[/source]

EDIT: and yeah it's just a pod struct Edited by joew
0

Share this post


Link to post
Share on other sites
[quote name='joew' timestamp='1351032191' post='4993249']
[quote name='Washu' timestamp='1351031983' post='4993247']
I'm CONFUSED?!?
[/quote]
So am I.... this change actually introduces a compile error for some wtf reason:

[source lang="cpp"]// Original
Rectangle& operator=(const Rectangle& rhs) : left(rhs.left), bottom(rhs.bottom), right(rhs.right), top(rhs.top) {}

// Replaced with
Rectangle& operator=(const Rectangle&) = default;
[/source]

EDIT: and yeah it's just a pod struct
[/quote]

If you're going to do one assignment operator, you should do both (move and copy).

As an additional note: VS2012 does not support default nor deleted Edited by Washu
0

Share this post


Link to post
Share on other sites
[quote name='Washu' timestamp='1351032266' post='4993250']
If you're going to do one assignment operator, you should do both (move and copy).
[/quote]
I do :)
0

Share this post


Link to post
Share on other sites
[quote name='Washu' timestamp='1351032266' post='4993250']
As an additional note: VS2012 does not support default nor deleted
[/quote]
Gross! I'll stick with clang which has the majority of the standard in [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

EDIT: FYI the issue was just that another class using Rectangle didn't have operator= defined ... that's nice it makes it easy to track down during a cleaning day like today Edited by joew
0

Share this post


Link to post
Share on other sites
I once used negative array indices in combination with a semi-Duff's Device - and winced in mixed horror/pride afterwards. But it was in the days when C-abuse like that used to please me (I've sinced learned).

Statements like this make me smile:
[code]if ((time = (newtime = GetTime ()) - oldtime) > 0)[/code]

Wouldn't do it in real code, but it gets a "hey! you can do this!" comment in stuff I'm fooling around with. Edited by mhagain
2

Share this post


Link to post
Share on other sites
[url="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization"]RAII[/url]

No seriously. I guess that says a lot about the codebases I've worked in ...
1

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1351041287' post='4993301']
My favorite hardly ever used part of C++ is pointers to members, if for no other reason than the fact that they're generally a counter example for memset() to 0 being the same as C++ assignment with 0.
[/quote]

Pointer-to-members are also my favorite part of the standard, though not for the same reason. I recently found myself doing this:
[code]
template<class T>
const Point2_t<T> Rect2_t<T>::corner( int idx ) const {
assert( 0 <= idx && idx < 4 );
T Rect2_t<T>::* const (&out)[2] = corners[idx];
return Point2_t<T>( this->*out[0], this->*out[1] );
}

template<class T>
T Rect2_t<T>::* const Rect2_t<T>::corners[][2] = {
{ &Rect2_t<T>::left, &Rect2_t<T>::bottom },
{ &Rect2_t<T>::right, &Rect2_t<T>::bottom },
{ &Rect2_t<T>::right, &Rect2_t<T>::top },
{ &Rect2_t<T>::left, &Rect2_t<T>::top }
};
[/code]

It's... It's beautiful (in a sadomasochism sort of way...)
2

Share this post


Link to post
Share on other sites
[quote name='Mussi' timestamp='1351135075' post='4993648']
I don't know how often it's used, but man do I love auto.
[/quote]
I think we'll see auto become heavily used in the future (at least I hope!) since it makes code so much more readable especially for things like iterators in for loops, etc. Although mind you I would very rarely do that now anyway considering you can for_each with a lambda or the new for loop syntax to cycle complete containers.

My favourite things that I use heavily but I'm guessing are underused at the time:
auto
for_each / lambda
default and deleted functions
final classes
override on virtual methods
nullptr Edited by joew
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0