O'Reilly logo

C++ Common Knowledge: Essential Intermediate Programming by Stephen C. Dewhurst

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Item 54. Traits

Sometimes it’s not enough to know just an object’s type. Often, there is information related to the object’s type that is essential to working with the object. In Embedded Type Information [53, 189], we saw how complex types like the standard containers often embed information about themselves within themselves:

image

The process algorithm works well with our Seq container but fails with a standard vector container, because vector does not define the nested type names that process assumes are present.

We can process a ReadonlySeq container because it validates our assumptions, but we may also want to process containers that do not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required