This is describing the inside of a class. No code gets executed here. This is a description of what's inside the class (a.k.a. struct). Putting f(x) there makes no sense. You're saying that B is a function that returns an object of type svv, and accepts an object of type f(x)? That doesn't make any sense.
If you want to specify that upon creation, this struct's object "B" should be initialised with whatever comes back from the function call f(x), you're going to need to write the constructor.
// reference to local variable of enclosing function is not allowed. // this is popup error message within vs2015 IDE.
error C2326: 'doRun::<unnamed-type-f>::<unnamed-type-f>(void)': function cannot access 'x'
note: This diagnostic occurred in the compiler generated function 'doRun::<unnamed-type-f>::<unnamed-type-f>(void)'
You'd have to post a *minimal* program that produces that message: there is no "doRun" in the code you're showing, and flow.cpp on that github is a wall of code
To fix the code you've shown in the original post (and to complete it to a minimal example)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <vector>
#include <iostream>
using sv = struct { int sym; int val; };
using svv = std::vector<sv>;
int x = 8;
svv f(int sz) { return svv(sz); }
struct
{
// svv B(f(x)); // Error: can't use parentheses here
svv B{ f(x) }; // OK: braces allowed
svv C = f(x); // OK: equals sign allowed
} A;
int main() {
std::cout << "A.B.size = " << A.B.size() << '\n'
<< "A.C.size = " << A.C.size() << '\n';
}
PS: I think your main problem here is attempting to define complex classes inside a function. Those "local classes" have a number of limitations, one of which is that references to a local variable in the enclosing function are not allowed, exactly as the compiler said.
Define classes at file (namespace) scope, and/or pass that x in as a constructor argument.