
"Arkadiy Vertleyb" <vertleyb@hotmail.com> writes:
"Daryle Walker" <darylew@hotmail.com> wrote
Wouldn't the program need exactly one master type-of list? Since C and C++ don't have cross-module consolidation, just text dumps of common files that work by "coincidence", couldn't you break ODR by:
File1.cpp: #include BOOST_TYPEOF_BEGIN_REGISTRATION() BOOST_TYPEOF_REGISTER_TYPE(greater_action); //1 BOOST_TYPEOF_REGISTER_TYPE(less_action); //2 BOOST_TYPEOF_REGISTER_TYPE(and_action); //3 #include BOOST_TYPEOF_END_REGISTRATION() int my_func1() { /*...*/}
File2.cpp: #include BOOST_TYPEOF_BEGIN_REGISTRATION() BOOST_TYPEOF_REGISTER_TYPE(placeholder<1>); //1 BOOST_TYPEOF_REGISTER_TYPE(less_action); //2 (only one the same) BOOST_TYPEOF_REGISTER_TYPE(greater_action); //3 #include BOOST_TYPEOF_END_REGISTRATION() int my_func2() { /*...*/}
I could, but I use anonimous namespaces to avoid this. This ensures every compilation unit has it's own set of encoding/decoding classes, and takes care of ODR.
I'm afraid it doesn't, technically, if typeof is used within a template that's seen in multiple translation units. That said, I'm willing to accept it if it really works. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com