Notes

Thoughts, write-ups, and things worth remembering.

using type alias

#cpp#keywords Updated Sep 16, 2026

Modern replacement for typedef — gives an existing type a new name.

using uPtr = std::unique_ptr<Node>;      // instead of: typedef std::unique_ptr<Node> uPtr;
using Vec = std::vector<int>;

uPtr node = std::make_unique<TranslateNode>(1, 0);

Where using actually wins over typedef: templates

template <typename T>
using Vec2 = std::pair<T, T>;   // a template alias

Vec2<float> point;   // works

typedef can’t do this — there’s no such thing as a “templated typedef.” using also reads left-to-right like a normal declaration, staying readable even for gnarly function-pointer types that typedef makes nearly unreadable.

unique_ptr