Which libraries use design patterns implemented using metaprogramming techniques at compile time?

Does anyone know of any libraries that use design patterns that are implemented using compile-time methods, for example. metaprogramming pattern? I know that Loki implements several, but I need to find other libraries.

+4
source share
5 answers

I think you're asking for libraries that help use the design pattern more than libraries that use design patterns, right?

Boost has a few, but not too many, for example, Flyweight - Design pattern for managing large amounts of redundant objects.

Not released, but accepted Boost.Factory library and rejected Boost.Singleton library

There are also some libraries that implement C ++ idioms like Boost.Pimpl (in the overview graph), Scope Exit (accepted), Memoizer.

0
source

Boost.Spirit is pretty big.

+6
source

It depends on which design template you are interested in. Some of them are similar to "Active Object" and Dispose, which at the time of compilation would be complex.

"interpreter" -> boost.ublas and blitz ++ use "expression patterns"

"bridge" pattern -> Each standard container accepts a "dispenser" argument (most of Loki are also bridge patterns)

"strategy" β†’ STL template functions select the best implementation based on argument types

The only difference in all of these cases is that the evaluation of the template occurs when the compiler is running, and not when the executable is running. So, all you need is to slightly change your thinking: templates are a program, and the β€œC ++ compiler” launches and interprets this program. The output of this template program is an object file ready for linking. In other words, the execution time of your precisley code template is when your compiler is running. C ++ templates are the full functional turing language, like lisp or XSLT.

In fact, the first metaprogram of the template in 1993 had as its output not an executable file, but a series of compiler errors that printed a sequence of fibonasias or something like that.

+2
source

Some libraries that use expression templates are: ublas, blitz, the matrix matrix template Library, ftensor, or the Google C ++ template matrix to find even more.

By the way, ftensor is really slick http://www.gps.caltech.edu/~walter/FTensor/FTensor.pdf .

+1
source

Dol almal GPG hier?

In any case, what is implemented in Loki: - Factory Abstract - Factory - Singleton - Visitor - Team

In accelerated weight

In the STL, do you have iterators and adapters, although I'm sure they don't take into account due to compilation time?

The original specification is somewhat vague.

Make sure you do not confuse universal programming (template-based implementation) with other compilation methods.

Does anyone know what this question means?

0
source

Source: https://habr.com/ru/post/1308545/


All Articles