Jump to content

  • Log In with Google      Sign In   
  • Create Account

TheComet

Member Since 02 Oct 2013
Offline Last Active May 20 2016 03:46 AM

Posts I've Made

In Topic: "It's when you...", or: little things you've discovered about...

03 March 2016 - 11:25 AM


Which are more useful on constructors since they wrap around the initialiser list:

 

Is it suppose to propagate if the constructor fails?

 

#include <iostream>


struct Foo
{
    Foo()
    {
        throw 6;
    }
};


struct S
{
    S() try : foo()
    {
        throw 6;
    }
    catch (...)
    {
        std::cout << "error in constructor" << std::endl;
    }


private:
    Foo foo;
    
};


int main()
{
    try {
        S* s = new S;
        delete s;
    } catch(...) {
        std::cout << "exception caught" << std::endl;
    }
}

I would have expected the above program to only print "error in constructor", but it prints both "error in constructor" and "exception caught".

 

This is the first time I've seen an object that was thrown once be caught twice.


In Topic: "It's when you...", or: little things you've discovered about...

02 March 2016 - 03:43 PM

When you realize a new technique to increment a variable.
 

#include <iostream>
#include <functional>

template <class Ret, class... Args>
struct ForLoop {
    ForLoop(std::function<Ret (Args...)> func) : func(func) {}
    operator const ForLoop*() const { func(); return this; }
private:
    std::function<Ret (Args...)> func;
};
int main()
{
    int b = 5;
    ForLoop<void> fl([&]() { ++b; });
    **********************************************************************fl;
    std::cout << b << std::endl;
}

In Topic: Procedurally-regenerating identical content on different machines (floating p...

18 February 2016 - 09:57 AM

Have you considered using fixed point numbers rather than floating point?


In Topic: Rising sea's

09 December 2015 - 06:05 AM

You're also just flat-out wrong. If I encouraged 10 other people to "go green" but din't alter my own lifestyle one jot, that would have MORE impact.


That would only be true if you assume those 10 people actually take the advice and alter their lifestyle. Chances are they're just like you: They hear the advice but they don't do jack about it because they think they are too insignificant to make a change. In a situation like that, if you change your lifestyle, your actions DO have an impact. But these scenarios are completely irrelevant because of what I said earlier.

If you change, you make the same impact than if you don't do anything at all. That's my point.
 

My personal actions make NO difference to overall climate effects


Do you really believe that? Simple things like turning off lights when you don't need them, using low power light bulbs, not flushing the toilet unnecessarily, taking short showers, etc. These all have a larger impact than what you might expect.

In Topic: Why didn't somebody tell me?

08 December 2015 - 07:52 PM

Cats. They are not dogs.

1) Dogs have four legs
2) Cats have four legs
3) Therefore, cats are dogs.

Checkmate atheists.

PARTNERS