Questions tagged [Metaprogramming] (9)

1
answer

How to write the second operator= in C++?

In addition to operator= I want to make a template:template <class T> void stealDataFrom(T& to, T& from); Some simple types this stealDataFrom obvious.class OverrideableInt { optional<int> autoValue, overrideValue; // actually a little wrong, but very similar } template <> void stealDataFrom(Over...
Annetta.Flatl asked April 3rd 20 at 16:45
3
answers

Possible self-modifying, recursive samoustraniajutsia their implementation of automated tests for the recursively self-modifying meta-programs?

Saying: 1. Objectively, there are metaprograms, i.e. the template code that generates a specific implementation of an algorithm with a specific set of internal parameters. 2. People - external to the AT a reasonable reality, which specifies the starting set of initial tests, requirements, restrictions, etc. a subject which...
chandler88 asked September 26th 19 at 06:36
4
answers

How to implement a decorator class in python?

Question to experts python. The initial task - it is necessary that one of the methods of the class turned around in decorators. This can be done through overriding this method and wrapping it through method_decorator.class MyView(View): @method_decorator(login_required): def dispatch(self, *args, **kwargs): return super(...
Maximo.Von asked September 18th 19 at 18:16
4
answers

Is it possible to initialize a static array algorithm?

If I need to fill a static array of say 8000-known numbers, do the c and c++ (preferably C) any tools for this? ie fill not sostatic const int a[3] = {1 , 2, 3}; and write something likestatic const int a[50]; for (int i = 0; i < 50; i++) a[i] = i; int main() {...} it is clear that you can fill in the header file script...
bernard_Krajcik asked August 23rd 19 at 12:21
2
answers

Dynamically assign the model attribute value using its name?

Failed to clearly formulate the question title. Will explain what you need. Model:class Item < ActiveRecord::Base has_one: subitem's end class subitem's < ActiveRecord::Base belongs_to: item end Somewhere in the controller:@item = item.new @item.subitem's = subitem's.new Now @item.subitem's not nil. Everything here ju...
claud_Kerluke asked August 15th 19 at 19:44
0
answer

Generated constructors and metaprogramming?

Generiruemoi for different parameters constructors(for example for different number of parameters) in the same Visual Studio is a metaprogramming or not?
raegan.Hue asked June 29th 19 at 16:38
0
answer

What is the difference between the descriptors and the Proxy?

the difference between them without considering the syntax that one may not another, and how it relates to meta-programming when meta-programming is changing the code during interpretation.
christelle_Feil asked June 14th 19 at 19:28
0
answer

How to swap items in the mpl::vector to derived classes were before their base?

I have a sequence of types. Check out what they all are classes and organize them so that derived classes were before their base. For a received sequence to check that all classes are derived from the latter. Need to implement a solution using Boost::MPL suppose we are given a list of types:class base1 {}; class child1 : b...
nikita.Stracke asked June 14th 19 at 16:31
1
answer

How to overload metamethod in JS?

In YAP Lua objects have metatables which contain metamethod - f-tsii called when working with objects, in fact this is object methods, such as adding a new item to the array, these metamethod you can overload... Interesting that there is metamethod which are caused not only when you explicitly call the method or properties ...
Tyrel20 asked June 8th 19 at 10:51
0
answer

Which of the 2 implementations more than acceptable?

Often there are situations when it is possible to equate an object to a function, and this f-tion will be called when certain conditions and parameters, but often this is not enough - I want some f-functions to hang for 1 object. For this purpose I have written 2 implementation. Actually I want to know which method is more ...
Tyrel20 asked June 3rd 19 at 01:23
  • 1