Questions tagged [policy-based-design]
56 questions
2
votes
1 answer
Policy based design: how to customize the Host structure in a proper way?
I have a bunch of algorithms and collections, and I am using a Policy Based design (see the book Modern C++ Design) to deal with arbitrary combinatorial complexity. This is great, but in order to prevent the destruction of the Host class by using…

tmaric
- 5,347
- 4
- 42
- 75
1
vote
2 answers
Convenienve of macros in case of a large template argument list
In my design, I have a class (let it be Shell) that is templated against a large number of parameters. Most of those parameters are other classes that I define within my project, since I have chosen a Policy-Based-Design approach for my project.
The…

enanone
- 923
- 11
- 25
1
vote
0 answers
ASPNETCORE ConfigureServices does not run
I follow the Microsoft document to implement the policy-based authorization in my web service but the function "ConfigureServices" does not run. Please let me know if I have something missing.
Startup.cs
using Microsoft.Owin;
using Owin;
using…

littlecodefarmer758
- 968
- 2
- 10
- 23
1
vote
2 answers
Creating a class template which can take a class made from itself as an argument
Is there a way to create a class template which can take an instantiation of itself as a template argument?
I would like to be able to say something this in my code:
Operation op1(0.3f);
Operation op2(0.5f, op1);
I tried…

stimulate
- 1,199
- 1
- 11
- 30
1
vote
1 answer
Policy based design - policy implementation has to access members of the host class
I think the best way to explain my question is with a piece of code:
class IncreasingMultiplier {
protected:
IncreasingMultiplier(int initialMultiplier = 0, int incrementation = 1)
int getMultiplier() {
mCurrentMultiplier +=…

saarraz1
- 2,999
- 6
- 29
- 44
1
vote
3 answers
multiple use of policies in policy-based design
i have a class template roundtrip which takes two policies. as long as they are different, everything is fine, but using one policy twice leads to compilation errors.
Example:
#include
class walk {
protected:
void move() {
…

the_ducky
- 165
- 1
- 12
1
vote
3 answers
Policy based design in a real world open source project
Can anybody point me to an open source C++ project(preferably not a lib), where policy based design is extensively used?

Shamdor
- 3,019
- 5
- 22
- 25
1
vote
1 answer
A C++ technique/library for combining a container and custom logic?
I have a need to occasionally process an object with a delay. The thread that's holding the object cannot delay, however.
A natural solution is to have a separate thread waiting for such objects. When an object becomes available, this second…

Philip
- 1,532
- 12
- 23
1
vote
1 answer
C++ policy based design.... base class as either sigleton or not based on template parametere.
The OutputPolicy of my class sometimes goes to a static/singleton object and sometime goes to a 1-to-1 object.
Not sure if I can explain in english.. so here is the desired behavior in pseudo code:
template<
class Algo,
template…

jaybny
- 1,026
- 2
- 13
- 29
0
votes
0 answers
Policy default template parameter fails when deducing template parameter value from concept
I got some code working where the first template parameter was deduced from the second predicate template parameter see this question. The solution to the former question (deducing the argument type from std::function + using a deduction guide) got…

WaterFox
- 850
- 6
- 18
0
votes
1 answer
How to declare a policy class that does nothing to a string, has consistent signature with other policies and is evaluated at compile-time
I am putting together a set of policy classes that operate a number of operations to a string. I would like these policies to be exchangeable, but the "do nothing" policy is problematic too me, as:
I don't see how to avoid copy using move semantic…

WaterFox
- 850
- 6
- 18
0
votes
0 answers
Policy-class design: how to add a CMake option selecting the desired class
I wrote the following traits that defines some policy classes:
namespace memory
{
struct on_RAM
{
template
using pop_sizes_type = PopulationSizeOnRAMImplementation;
template
using…

WaterFox
- 850
- 6
- 18
0
votes
1 answer
how do I forward the templates arguments onto the std::make_unique when creating policy based class?
Lets assume I'm using policy based templates design pattern (see https://en.wikipedia.org/wiki/Modern_C%2B%2B_Design).
I'm having some issue related to how would I use std::make_shared (or std::make_unique for that matter) for creating new type Bar,…

IdanB
- 303
- 4
- 9
0
votes
1 answer
Zero-dependency traits definition
I am experimenting and trying to make a template policy-based meta library. Example case is aggregating 2 classes for a device driver.
The classes implement device_logic and connection_logic, they don't need to depend on each other's type:
device…

Sergey Kolesnik
- 3,009
- 1
- 8
- 28
0
votes
2 answers
How to set Variadic CRTP base classes to be friend's of the derived class
Main parts of the problem is using CRTP with a policy based design and variadic template. From the policy can't reach the protected or private members from the main/derived class. Because of using variadic template I can't declare policies just as…

István Simon
- 173
- 8