Tag Archives: caveats

C++ Streams & Typedefs: Be Charful

The C++ type­def key­word is indis­pens­able in many sit­u­a­tions, espe­cial­ly for writ­ing portable low-lev­­el code. However, in some cir­cum­stances it can cause trou­ble, par­tic­u­lar­ly when it comes to func­tion over­load­ing. Consider the fol­low­ing C++ tem­plate class: tem­plate <type­name T> struct foo­bar {     foo­bar( con­st T foo ) : foo_( foo ) {} […]