title: Performance: typedef vs wrapper class for primitive types?
body: <p>I want to define a new type in C++ which is just some primitive type (in my example an <code>int</code>, could be any type). I call the type <code>NodeId</code> in this example. </p>
  
  <p>I could just use <code>typedef int NodeId</code>. I want a default value for <code>NodeId</code>s, so I would use <code>#define NULL_NODE_ID -1</code>.</p>
  
  <p>Now, I think it would be nicer to define a class instead of <code>typedef</code> to allow a function <code>isValid()</code> and a default constructor constructing a null <code>NodeId</code>:</p>
  
  <pre><code>class NodeId
  {
      int value;
  public:
      inline NodeId() : value(-1) {}
      inline NodeId(int value) : value(value) {}
      inline operator int() {return value;}
      inline bool isValid() {return value != -1;}
      //...
  };
  </code></pre>
  
  <p>Are there any performance disadvantages which result in using the second method?</p>