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
1
vote
2 answers

Why am I getting "error: no match for ‘operator->*’" when the parameters on both sides look correct?

I'm trying to call a function from within a template function inside a template. The call itself, however, doesn't compile, instead I get the following error: /home/alexis/tmp/b.cpp: In instantiation of ‘bool callback_manager::call_member(F, ARGS…
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
1
vote
1 answer

Seg fault when using multiple levels of indirection

When allocating and then attempting to access an array of pointers to pointers: void tester(char ***p) { int i; char **pp; pp = *p; pp = calloc(10, sizeof(*pp)); for (i = 0; i < 10; i++) printf("%d = %p\n", i, pp[i]); …
mattitude
  • 13
  • 3
1
vote
3 answers

Invalid Indirection in C++

This is my program. I dont know what to do next because I dont know what is invalid indirection. The error is found from line 46 to 52. #include #include #include #include int main() { int d, c; double fx,…
1
vote
1 answer

Bash: append (+=) to nameref (-n) to hash key

In bash 5.0.17, s='X'; declare -n s2=s s2+=YYY; declare -p s correctly yields declare -- s="XYYY". So far so good. Now, what if I make a nameref to an associative array key? declare -A aa aa=( [k1]=v1 ); declare -n 'nk1=aa[k1]' nk1+=YYY; declare -p…
usretc
  • 723
  • 4
  • 9
1
vote
1 answer

Function does not see locals in exec with supplied locals

Consider this working code: x=123 def printx(): print(x) If I execute printx() the output would be 123 as x value exists in locals() and printx sees that. I can also get x value like this: locals()["x"] But I need to run my function in exec…
rfg
  • 1,331
  • 1
  • 8
  • 24
1
vote
4 answers

Execute command that results from execution of a script whose name is in a variable

When posting this question originally, I totally misworded it, obtaining another, reasonable but different question, which was correctly answered here. The following is the correct version of the question I originally wanted to ask. In one of my…
Enlico
  • 23,259
  • 6
  • 48
  • 102
1
vote
1 answer

Simple indirection approach for linking to images

I have a web site which hosts images are shared and linked directly. I've read somewhere that this is a bad idea. How could I apply simple indirection approach while perhaps keeping existing links up for a while until they disappear off Facebook?
James P.
  • 19,313
  • 27
  • 97
  • 155
1
vote
0 answers

Get array size with indirect name reference

I am trying to get the size of an array, but I don't know the array name until runtime (it's built dynamically based on a list from a file), so I am trying to use bash indirection with ${!var}. This answer comes very close (How to iterate over an…
Slav
  • 27,057
  • 11
  • 80
  • 104
1
vote
1 answer

Indirect expansion returns variable name instead of value

I am trying to set up some variables using indirect expansion. According to the documentation I've read, the set up should be simple: var1=qa qa_num=12345 varname="${var1}_ci" echo ${!varname} I should be getting "12345". Instead, the output is…
SVill
  • 331
  • 5
  • 22
  • 55
1
vote
1 answer

Array indirection issue

I have an issue with array indirections in C. Let's declare an array : int tab[3]; How can these three variable display the same result ? It looks like the memory cell of the tab contains the adress itself AND the first value. I don't…
Pierre FG
  • 11
  • 2
1
vote
1 answer

If Statement Against Dynamic Variable

I am attempting to do something similar to the following ... New-Variable -Name "state_$name" -Value "True" if ("state_$name" -eq "True") { Write-Host "Pass" } else { Write-Host "Fail" } I have attempted this a number of different ways but…
1
vote
1 answer

Bash redirect all output to named pipes

I've been looking for a way to use Bash indirection to re-route all outputs (1 (STDOUT), 2 (STDERR), 3, etc.) to named pipes. Here is a script that I wrote to test this…
Zeitwechsler
  • 53
  • 1
  • 7
1
vote
2 answers

How can I create a flat dictionary from a nested dictionary whose keys are a subset of a reference dictionary?

I am creating a nested reference dictionary to record all possible keys a data dictionary could have with corresponding values which are all the keys to be used in the flat dictionary. The data dictionary's keys will always be a subset of the keys…
1
vote
2 answers

Include indirection on Visual C++

Let's say we have an application that will need Boost to compile. Boost being an external library, updated regularly, and our application having multiple binaries and multiple versions ("multiple" as in "Let them grow and multiply"... don't ask...),…
paercebal
  • 81,378
  • 38
  • 130
  • 159
1
vote
1 answer

Linux Bash how to grab output and put it back in the script using for loop

Variable's value in bash can be easily called with echo $var command like this user@linux:~$ a=1; b=2; c=a+b user@linux:~$ echo $a $b $c 1 2 a+b user@linux:~$ What I'm trying to accomplish is to replace x with the actual value in…
user9013730