Two minor language questions
1. This compiled in GCC, but is it okay to return a void type in a void function?
Code:
void g() {}
void f() { return g(); }
int main() { f(); }
2. Does "forwarding" inlined functions incur any overhead? Tell me if the first code should run any differently from the second.
Code:
struct func
{
void operator()() { /*something*/ }
};
Code:
struct func
{
func(bool which_) : which(which_) {}
void operator()() { return which ? fun1() : fun2() }
void fun1() { /*something*/ }
void fun2() { /*something similar*/}
private:
bool which;
};
I'm trying to add a feature, without any overhead, and without having to rewrite a ton of code. My advisor has "but now we should make it do this" syndrome.
Thanks in advance for all of your wisdom.
*edit* I could use virtual functions for #2. Would that be efficient?