Questions tagged [template-mixins]

19 questions
21
votes
3 answers

Are there scala-like mixins for C++?

Scala Mixins
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
5
votes
1 answer

Visibility rules for mixin inheritance with variadic template

Consider I inherit from a variadic template the entire arguments list. How are the arguments inherited? // snippet template class foo : public R... { public: }; // .... using foo_inst = foo; I tried it, and it…
user1810087
  • 5,146
  • 1
  • 41
  • 76
5
votes
0 answers

Is Mixin a special case of Policy-Based Design?

As far as I know, mixin is when you first write the derived class, and then you can inject the base class to it through a template parameter. Example: http://www.drdobbs.com/cpp/mixin-based-programming-in-c/184404445 As I know Policy-based design is…
Melkon
  • 418
  • 3
  • 12
5
votes
2 answers

Twitter Bootstrap ".container" class: How to use it semantically?

One day ago I decided to play around with Twitter Bootstrap. Found it fantastically well crafted, but Im not a fan of all of those classes polluting my html. So I´m trying to use Less to make it more semantic. I was doing quite good til I step over…
darksoulsong
  • 13,988
  • 14
  • 47
  • 90
4
votes
5 answers

How do people get mixin-style re-use in C#?

I come from a C++ background where I can use template mixins to write code that refers to FinalClass which is a template parameter that is passed in. This allows reusable functions to be "mixed-in" to any derived class, by simply inheriting from…
Jesse Pepper
  • 3,225
  • 28
  • 48
4
votes
1 answer

Passing a tuple to a variadic mixin class

I'm trying to forward a series of parameters to two different mixin classes as follows: template class Checker : public Checkers... { public: template Checker(Args&&... args) :…
TimeHorse
  • 510
  • 3
  • 14
4
votes
3 answers

Mixin template for defining structs with identical member

I want to define a number of structs, each starting with the same member: struct A { S s; // same member X x; // other members } struct B { S s; // same member Y y; // other members } What is a mixin template to achieve this?
Core Xii
  • 6,270
  • 4
  • 31
  • 42
3
votes
2 answers

Use pug mixin result as attribute value

Here is a boiled-down version of what I'm trying to accomplish: mixin foo(bar) = bar + ".html" a(href= +foo("baz")) test I'd like to have the anchor tag be compiled as test, but what I'm getting instead are type errors,…
gandreadis
  • 3,004
  • 2
  • 26
  • 38
3
votes
1 answer

Generic Components Friendly To Software Transactional Memory

Say we write some new class which can be used concurrently or not. Obviously, we don't want to have locks on everything on the chance that they will be called concurrently. One way to address this is through parameterizing by mixins specifying…
Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
2
votes
1 answer

Combine capabilities of classes (mixins) with ambiguous calls

I was reading about the "mixin" technique in C++ but there is something I don't understand and seems to be a limitation in the language that prevents to do it generically because of ambiguities that the compiler (and the standard refuse to resolve,…
alfC
  • 14,261
  • 4
  • 67
  • 118
2
votes
1 answer

mixin into every non-abstract subclass in D

I have created a framework in witch each class deriving from Action needs to have some magic features like static methods etc. that depend on this class fields. I am using a mixin template to achieve this: mixin template ACTION(T:Action){ …
fsw
  • 3,595
  • 3
  • 20
  • 34
2
votes
1 answer

How to write an input filter that is policy-friendly?

Background: Our software uses multiple APIs to do file i/o: FILE*, CStdio (and several derivatives), HANDLE, ... I wrote a FilePointer RAII wrapper for FILE*, which has served us well as a drop-in replacement for all of the existing C code. Newer…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
1
vote
1 answer

Creating a typetuple from a variadic template argument list in D

I have a templated struct of the following form: struct Command(T) { alias T CommandType; // ... } In addition, I have another container struct that holds a bunch of these Command structs: struct CommandList(Command...) { } What I'd like…
Mark LeMoine
  • 4,478
  • 3
  • 31
  • 52
1
vote
3 answers

Call constructor of mixin base classes based on number of arguments

I have two sets of mixin base classes that follow the following pattern // base class taking one contructor argument struct OneArgBase { const double x; template OneArgBase(const T & t) : x(t.x) {} }; // base class taking…
1
vote
0 answers

Possible to inherit from variadic specified classes?

Is it possible to do something like: template class multi : public t1, public t2, ... { ... }; Where t1 is the first template argument, t2 the second, and so forth. Thanks in advance, and I will clean up the formatting when I get access…
user318904
  • 2,968
  • 4
  • 28
  • 37
1
2