a possible typeof addition

Hi All, Do you think it makes sense to write a utility that, using a syntax like following: template<class T, class U> class foo /*typeof*/ { . . . }; struct bar /*typeof*/ { . . . }; // etc. would generate the typeof registrations? I think it could be quite helpful to those library authors who want to make their libs typeof-enabled, since it would minimise the duplication issue... This utility could be written using Spirit or maybe Python or any other suitable tool. Please let me know. Regards, Arkadiy

Arkadiy Vertleyb wrote:
Hi All,
Do you think it makes sense to write a utility that, using a syntax like following:
template<class T, class U> class foo /*typeof*/ { . . . };
struct bar /*typeof*/ { . . . };
// etc.
would generate the typeof registrations? I think it could be quite helpful to those library authors who want to make their libs typeof-enabled, since it would minimise the duplication issue...
This utility could be written using Spirit or maybe Python or any other suitable tool.
YES!!! -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

"Joel de Guzman" <joel@boost-consulting.com> wrote
Arkadiy Vertleyb wrote:
Hi All,
Do you think it makes sense to write a utility that, using a syntax like following:
template<class T, class U> class foo /*typeof*/ { . . . };
struct bar /*typeof*/ { . . . };
// etc.
would generate the typeof registrations? I think it could be quite helpful to those library authors who want to make their libs typeof-enabled, since it would minimise the duplication issue...
This utility could be written using Spirit or maybe Python or any other suitable tool.
YES!!!
I played with this a bit (using Spirit), and the most challenging part seems to be parsing the default parameters, which can be complicated expressions, for example: template<class T, int n = traits<T*>::size + 1> class x{}; I don't actually need to parse it, just to skip till the next comma or angle bracket (considering nesting). What would be the easiest way to accomplish this? A custom parser? Also, maybe I am re-inventing the wheel -- are there any Spirit parsers to assist in working with the C++ grammar? Regards, Arkadiy

Arkadiy Vertleyb wrote:
"Joel de Guzman" wrote
Arkadiy Vertleyb wrote:
Hi All,
Do you think it makes sense to write a utility that, using a syntax like following:
template<class T, class U> class foo /*typeof*/ { . . . };
I played with this a bit (using Spirit), and the most challenging part seems to be parsing the default parameters, which can be complicated expressions, for example:
template<class T, int n = traits<T*>::size + 1> class x{};
I don't actually need to parse it, just to skip till the next comma or angle bracket (considering nesting).
Don't forget comments! ;-) Jonathan

Jonathan Turkanis wrote:
Arkadiy Vertleyb wrote:
"Joel de Guzman" wrote
Arkadiy Vertleyb wrote:
Hi All,
Do you think it makes sense to write a utility that, using a syntax like following:
template<class T, class U> class foo /*typeof*/ { . . . };
I played with this a bit (using Spirit), and the most challenging part seems to be parsing the default parameters, which can be complicated expressions, for example:
template<class T, int n = traits<T*>::size + 1> class x{};
I don't actually need to parse it, just to skip till the next comma or angle bracket (considering nesting).
Don't forget comments! ;-)
Why not build it on top of Wave :D? Or even build it as an extended-Wave that adds the typeof information as part of it's preprocessed output? - Reece
participants (4)
-
Arkadiy Vertleyb
-
Joel de Guzman
-
Jonathan Turkanis
-
Reece Dunn