I don't see how this is superior to writing the brief-version as a synopsis
comment
and just writing the actual class definition with the member function
template definitions in it.
I don't see why that shoukd not work. I like the idea. Variables declared in it automatically could become variable templates.
El 22/5/2015 12:20, "Douglas Boffey" <douglas...@gmail.com> escribió:
>
> Consider:
>
> template <typename T>
> class Foo {
> // whatever
> public:
> void bar();
> void baz();
> void another_fn();
> // ...
> };
FWIW, I think that something similar has been proposed some years ago:
//no namespace version:
namespace class Foo {
void bar() { ... }
void baz() { ... }
}
// templated version:
template <typename T>
namespace class Foo {
void bar() { ... }
void baz() { ... }
...rest of the definitions
}
It was slightly different since blocks are class-specific.
I don't remember what crushed this.
>
> To define the functions, you would have to write:
>
> template <typename T>
> void Foo::bar() { /* ... */ }
>
> template <typename T>
> void Foo::baz() { /* ... */ }
>
> template <typename T>
> void Foo::another_fn() { /* ... */ }
>
> Wouldn’t it be better if we could write:
>
> template <typename T> {
> void Foo::bar() { /* ... */ }
> void Foo::baz() { /* ... */ }
> void Foo::another_fn() { /* ... */ }
> }
>
> Pro:
> - less typing (although that is not the motivating reason)
> - cleaner, clearer syntax, improving maintainability
> - easier to check correctness
>
> What do people think?
>
El 23/5/2015 10:09, escribió:
>
>
> El 22/5/2015 12:20, "Douglas Boffey" <douglas...@gmail.com> escribió:
> >
> > Consider:
> >
> > template <typename T>
> > class Foo {
> > // whatever
> > public:
> > void bar();
> > void baz();
> > void another_fn();
> > // ...
> > };
>
> FWIW, I think that something similar has been proposed some years ago:
>
> //no namespace version:
Errata: "non template version"