someVariable = { somethingThatLooksLikeAFunction }; possible? Wasn't sure how to title this question...

I was curious whether the title example is possible somehow, and are there any good tricks to using it?

I have been using something similar quite a lot:

newBool = (someTest) ? true:false;
newInt  = (x + (y / z));
[...]


However, I was curious if it was possible to add far more conditions, almost like a function?

For some simple(*) examples:

someThing = { 
    int _x = aFunction(_x);
    if(_x) { 
        something = somethingElse;
        for(...){ ... }; // etc
    } else {
        /* otherStuff */
    } 
};


Or

someThing = {
    for(_x=0;_x&lt;y;_x++){
        z++;
    }
    someThing = (z&gt;y) ? a:b;
};


I understand it's worth just separating it off into functions most of the time, although I'm trying to get away from a function/library-fest as much as possible...  It's getting annoying crawling through everything when I could just have the useful stuff right there, where I need it, instead of 1000 lines away, or in another library.  It also allows the text editor to fold the code out of sight, starting from one variable, instead of on each clause.

With the few tests I have tried, I've not been successful in achieving what I'm experimenting with, so, is this kind of thing possible in any way? and if so, what are the rules/possibilities/different ways you could implement this?

* Emphasis on simple! And a semi-pointless/completely useless "function" alert too!  I'm just curious about the "proof of concept" in the examples...
You can do it with a lambda function, though the syntax is somewhat cryptic:

int someThing = [](int y, int z, int a, int b){
    for (int _x = 0; _x &lt; y; _x++) {
        z++;
    }
    return (z &gt; y) ? a : b;
}(100, 0, 10, 20);


In that you are defining a lamda function [] with four parameters, y, z, a and b. Then calling that function with four numbers (100, 0, 10, 20) and assigning the return value to someThing.

It's the same as writing a normal function but there's a lot more brackets around.