Skip to Main Content
Intel Threading Building Blocks
book

Intel Threading Building Blocks

by James Reinders
July 2007
Intermediate to advanced content levelIntermediate to advanced
332 pages
10h 4m
English
O'Reilly Media, Inc.
Content preview from Intel Threading Building Blocks

Concepts in Generic Programming

Generic programming is supported in C++ through the notion of templates. The templates provide abstraction while retaining the opportunity for optimal performance.

A Concept is a set of requirements on a type and is represented in this book in Pascal-Case (a style of combining words into keywords by capitalizing the first letters in each word). The requirements may be syntactic or semantic. For example, the Concept of Sortable could be defined as a set of requirements that enable an array to be sorted. A type T would be Sortable if:

  • x < y returns a Boolean value, and represents a total order on items of type T.

  • swap(x,y) swaps items x and y.

You can write a sorting template function in C++ and be assured that it can sort an array of any type that is Sortable.

We describe the requirements you should observe on types for Threading Building Blocks types in this book as Concepts. When these constraints are followed, Threading Building Blocks will work well. When they are violated, you may get a cryptic compiler error message or occasionally inefficient or incorrect code. There is a great deal of interest in designing a type system for C++ that can check template arguments for errors. In the future, we may have extensions to C++ that allow more type constraints in the template definitions. This will lead to more safety and better error messages from the compiler.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Rezaur Rahman

Publisher Resources

ISBN: 9780596514808Errata Page