Questions tagged [indirection]

Any of various programming concepts related to the level of abstraction applied to a particular problem, algorithm or scenario. Examples may include substituting higher-level programming constructs where previously lower-level constructs were previously applied.

Indirection

Any of various programming concepts related to the level of abstraction applied to a particular problem, circumstance, algorithm or knowledge domain.

160 questions
7
votes
3 answers

Overloading the indirection operator in c++

my problem is a simple one. I have a class template that holds a pointer to a dynamically allocated type. I want to overload the indirection operator so that referring to the class template instance with the -> operator I get redirected as if I use…
dtech
  • 47,916
  • 17
  • 112
  • 190
7
votes
1 answer

Is There a Indirection Functor?

I'm looking for a unary functor which will dereference it's argument and return the result. Of course I can write one, it just seemed like something should already exist. So given the code: const auto vals = { 0, 1, 2, 3 }; vector
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
6
votes
4 answers

What does declaring and instantiating a c# array actually mean?

I am reading up on c# arrays so my question is initially on arrays. What does declaring an array actually mean? I know you declare a variable of type array. When I have the following, what is actually happening? int[] values; Is it in memory by…
Brendan Vogt
  • 25,678
  • 37
  • 146
  • 234
5
votes
2 answers

Calling dynamic variable in PowerShell

I am trying to create a new variable that would use other variable with dynamic name as its value. Here's what I am trying to do: I have a System.Array with two values: $Years = 2015, 2016 Another variable, $Transactions has a list of various…
user6744606
5
votes
1 answer

Assign to a bash array variable indirectly, by dynamically constructed variable name

Bash script to create multiple arrays from csv with unknown columns. I am trying to write a script to compare two csv files with similar columns. I need it to locate the matching column from the other csv and compare any differences. The kicker is…
user3666718
  • 51
  • 1
  • 3
4
votes
1 answer

Get the value of an environment variable whose name is stored in a variable

I am trying to figure out an easy to read and understandable idiom that evaluates the the value of an environment variable whose name is stored in a variable: $varName='TEMP' I have come up with $val = invoke-expression "`$env:$varName" and am…
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
4
votes
3 answers

PowerShell - How do I call a variable with another variable?

I have this code: $var_Cart="text cart" $var_Cat="text cat" $var_Home="text home" $names = "Cart","Cat","Home" foreach ($name in $names) { $variable="var_$name" Write-Host "`n`-----Print "$variable"-----" } how can i get to print "text…
4
votes
2 answers

How can I reference an existing bash array using a 2nd variable containing the name of the array?

My closest most helpful matches when I searched for an answer ahead of posting: Iterate over array in shell whose name is stored in a variable How to use an argument/parameter name as a variable in a bash script How to iterate over an array using…
Pytheas
  • 43
  • 5
4
votes
1 answer

Is there a way to reference a particular element in a yaml array?

Is there a way to reference a particular element in a yaml array? For example if I have this bit of yaml: node_list: - one - two - three Can I do something like this: first_node: node_list[0]
Red Cricket
  • 9,762
  • 21
  • 81
  • 166
4
votes
1 answer

Evaluate Color Formatted Output of Command

I am using diff to format a string that includes tput color variables, and am unable to have those variables evaluated without using the "evil" eval command. The command that creates the string: output1="$(diff…
akovia
  • 117
  • 8
4
votes
6 answers

Intuitively explaining pointers and their significance?

I'm having a hard time understanding pointers, particularly function pointers, and I was hoping someone could give me a rundown of exactly what they are and how they should be used in a program. Code blocks in C++ would be especially…
Bob John
  • 3,688
  • 14
  • 43
  • 57
3
votes
1 answer

Warning C4047 : 'int **' differs in level of indirection from 'int[2][4]'

I'm getting this warning and scratching my head about why. I found many thread here that address this warning in VS 2017 compiler, but not this particular combination: why isn't int** the same level of indirection as int[X][Y]? Here's a distilled…
DMK
  • 53
  • 4
3
votes
1 answer

Can gcc inline an indirect function call through a constant array of function pointers?

Let's say we have this code: inline int func_2 (int a, int b) { return time() + a * b; } int main (void) { int x = (int (*[])(int, int)){func_1, func_2, func_3}[1](6, 7); } Can gcc be somehow tricked to really inline the indirect calls to…
Blagovest Buyukliev
  • 42,498
  • 14
  • 94
  • 130
3
votes
1 answer

cost of unwrapping a std::reference_wrapper

Given: #include #include template // Just for overloading purposes struct behaviour1 : std::reference_wrapper { using base_t = std::reference_wrapper; using base_t::base_t; // This…
ABu
  • 10,423
  • 6
  • 52
  • 103
3
votes
2 answers

what is the javascript mechanism/rules that allow `p.foo = o.foo` to return a reference to the function `foo`?

I'm currently studying javascript by following the book "you dont know js" series. In the "this & object prototype" section, when discussing "indirect references to functions", the author states function foo() { console.log( this.a ); } var a…
Thor
  • 9,638
  • 15
  • 62
  • 137
1
2
3
10 11