Jump to content
  • Advertisement
  • entries
  • comments
  • views


Recommended Comments

a friend rolled his own for his event system. there seems to be alot of uses for traits, especially when passing parameters around (the classic "pass a copy for PODs and const refs for the rest"). I'd sure like to hear more, especially the one proposed to C++ :D

Share this comment

Link to comment
Well, yes...



...only if you talk about runtime implementation...

...I have no idea what you're talking about.


Share this comment

Link to comment
Washu, you know we're going to read and enjoy anything you write. Plus, it'd be great to read some of your insights on C++ for a change (as opposed to the usual .NET tidbits). In short:


Share this comment

Link to comment
I use type traits quite abit in my code but less on its own more with boost MPL. I have some simple code that does what Seriema was describing about passing parameters by value or constant reference:

#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_fundamental.hpp>

template < typename Tq >
struct param_type : public boost::mpl::eval_if<
boost::add_reference<Tq const>
> {};


template < typename Tp >
struct foo { void bar(typename param_type<Tp>::type) {} };

its nifty [grin].

There is all kind of things you can do even make domain specific embedded languages, if you get the book C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond you'll see all the ways in which you can use them.

Share this comment

Link to comment

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!