JoeJ said:
// C:
for (size_t i=0; i<elements.size(); i++) elements[i].Do();
@joej Where does size() live, what is elements here in your “C” snippet?
JoeJ said:
Maybe there is a solution for a kind of static if i don't know about…
So i'd like to do something like this:
template <class Vec3>
void Stuff (const Vec3 &p)
{
Vec3 q;
static_if (Vec3==SimdVec3)
{
q = SimdVec3::minPerElement(p, Vec3(1));
}
static_else
{
q[0] = min(p[0], 1);
q[1] = min(p[1], 1);
q[2] = min(p[2], 1);
}
But seems not possible?
@joej Couldn't you specialize Stuff to run with <SimdVec3> that wouldn't just be static, it would be compile-time. Perhaps that doesn't solve your problem?
h8CplusplusGuru said:
if you want to create a named scope, you would use a lambda:
auto a = [&]()->auto{ int a = 10; return a+10; };
int b = a();
lambdas are the new c++ paradigm, you should practice them.
@h8cplusplusguru I think [&]()→auto
is a little out there on account of the return type - at least I'd just infer the type if it's like that, but I get what you mean.
I tend to agree with @gnollrunner , it's most important to learn and practice general software development disciplines; algorithms, system architecture, project organisation.
The language features can be the sugar on the top, but sometimes they're so empowering that they change the landscape of the disciplines drastically. Like with templates and lambdas for instance, powerful stuff.
I enjoy a lot of things about C++. For instance that you can do something like metafunctions. That's just so cool, and isn't something I thought of first off, when I was introduced to templates.