Marker traits

Traits defined in the std::marker module are called marker traits. These traits don't have any method, and simply have their declaration with their name with an empty body. Examples from the standard library include Copy, Send, and Sync. They are called marker traits because they are used to simply mark a type as belonging to a particular family for to gain some compile time guarantees. Two such examples from the standard library are the Send and Sync traits that are auto-implemented by the language for most types whenever appropriate, and convey which values are safe to send and share across threads. We'll get to know more about them in Chapter 8, Concurrency.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset