![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
THE BOOST MPL LIBRARY: DetailsBoost , ,
|
Front Page / Tutorial: Metafunctions and Higher-Order Metaprogramming / Details |
К настоящему времени вы должны иметь достаточно полное представление о фундаментальных понятиях и языке как шаблонного метапрограммирования в целом, так и Библиотеки повышения метапрограммирования. В этом разделе рассматриваются основные моменты.
Most of this book's examples will use the Boost Metaprogramming Library. Like the Boost type traits headers, MPL headers follow a simple convention:
#include <boost/mpl/component-name.hpp>
If the component's name ends in an underscore, however, the corresponding MPL header name does not include the trailing underscore. For example, mpl::bool_ can be found in <boost/mpl/bool.hpp>. Where the library deviates from this convention, we'll be sure to point it out to you.
A kind of lambda expression that, through the use of placeholders, enables in-place partial metafunction application and metafunction composition. As you will see throughout this book, these features give us the truly amazing ability to build up almost any kind of complex type computation from more primitive metafunctions, right at its point of use:
// find the position of a type x in some_sequence such that: // x is convertible to 'int' // && x is not 'char' // && x is not a floating type typedef mpl::find_if< some_sequence , mpl::and_< boost::is_convertible<_1,int> , mpl::not_<boost::is_same<_1,char> > , mpl::not_<boost::is_float<_1> > > >::type iter;
Placeholder expressions make good on the promise of algorithm reuse without forcing us to write new metafunction classes. The corresponding capability is often sorely missed in the runtime world of the STL, since it is often much easier to write a loop by hand than it is to use standard algorithms, despite their correctness and efficiency advantages.
Статья THE BOOST MPL LIBRARY: Details раздела может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: ::
реклама |