c++ - problem with enums in namespaces, and operator-> in templates
- 8irmer informatik.uni-hamburg.de (37/37) Nov 13 2002 Hi,
- Mac Reiter (8/34) Nov 13 2002 Actually, I believe that it is more than just "more convenient". From
Hi, I tried out dm and encountered two problems. 1.) Declaration of enum constants in namespaces: Example: namespace storage { enum type { dumb, place, pool, heap }; } If i try to explicitely use these constants, like unsigned int test = storage::heap; -> error: namespace storage has no member heap (while implicitely using them works ok, like enum storage::type test = heap; -> ok ) 2.) Problems with overriden operator->() in templates If i have overriden the -> operator in a template class, and i instantiate it with something where -> doesn't makes sense, i get an error (even if i don't use the -> operator). The dm compiler should only instantiate those templates which are really needed, this would be more convenient. For example the gnu gcc and visual c++ 7.0 doesn't complain, if you don't use the template operator->() class Test { public: double m; } smartptr<Test> p1; p->m = 0.3; // ok smartptr<int> p2; // ok if you don't use '->' Best regards Norbert Irmer
Nov 13 2002
8irmer informatik.uni-hamburg.de wrote:Hi, I tried out dm and encountered two problems. 2.) Problems with overriden operator->() in templates If i have overriden the -> operator in a template class, and i instantiate it with something where -> doesn't makes sense, i get an error (even if i don't use the -> operator). The dm compiler should only instantiate those templates which are really needed, this would be more convenient. For example the gnu gcc and visual c++ 7.0 doesn't complain, if you don't use the template operator->()Actually, I believe that it is more than just "more convenient". From what I can tell, the standard actually requires that unused template members _must_not_ be instantiated. I don't have the standard itself sitting around, but I've seen enough references to designs that rely on the non-instantiation that I feel relatively confident that it is in the standard.class Test { public: double m; } smartptr<Test> p1; p->m = 0.3; // ok smartptr<int> p2; // ok if you don't use '->' Best regards Norbert IrmerMac
Nov 13 2002