• Advertisement
Sign in to follow this  
  • entries
    195
  • comments
    198
  • views
    104082

Bad code here

Sign in to follow this  

75 views

For those of you that remember this journal entry, I was playing around with the evilness and found a couple of problems with the macro. Here's what the current version looks like now:

template
struct LtProxy {
public:
LtProxy(T r) : ref_(r) {}
T ref_;
private:
LtProxy & operator=(const LtProxy &);
};

#define MAKE_OPERATOR(name, lhs_type, rhs_type, result_type, worker_function) \
const struct name ## _t {} name; \
inline LtProxy operator <(lhs_type lhs, name ## _t) { \
return LtProxy(lhs); \
} \
inline result_type operator>(const LtProxy & lhs, rhs_type rhs) { \
return worker_function(lhs.ref_, rhs); \
}



It's still bad code, but it's better bad code. As in, it compiles in more situations and produces fewer warnings.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement