Typedef or using the keyword when exposing the external library class in my namespace

advertisements

I want to expose a class from an external library to my library's users. Specifically I want to 'import' the class to my namespace so that the user does not need to know what libraries I am using behind the scenes. Often it seems that I can either do this by using a typedef, or by simply using the class. Is there any reason for choosing one method over the other (or doing something else)? (I seem to have some gaps in my education :) )

For example: I want to create a serial port manager that uses Boost::Asio.

namespace MySerialManager {
  //should I use a typedef
  typedef boost::asio::serial_port_base::flow_control flow_control ;
  //or a using...
  using boost::asio::serial_port_base::flow_control;

  class SerialManager
  {
    //let the user specifify the flow on construction
    SerialManager(const flow_control& fc);
  }
}

or should I be doing something else altogether.... Many thanks.


If you wanted to "import" a class template, then using would be your only option. As it stands, I don't think there's any substantial difference. Personally, I'd go for typedef in the above case, because it's an older and more familiar construct.