 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kaba Guest
|
Posted: Thu Apr 12, 2007 4:08 am Post subject: Template classes in C++0x |
|
|
Consider a template class that has lots of parameters:
template <typename C1, typename C2, typename C3, etc>
class A
{
public:
void f();
voif g();
};
Now defining the member functions outside of A, f and g require lots of
code to specify the class around them:
template <typename C1, typename C2, typename C3, etc>
void A<C1, C2, C3, etc>::f()
{
}
template <typename C1, typename C2, typename C3, etc>
void A<C1, C2, C3, etc>::g()
{
}
There clearly is redundancy here. It would be beneficial to group the
definitions to blocks which defines the surrounding class. I know there
has been a proposal to do just this, but I can't quite find it in the
current proposal list. Now I'm concerned if there is no proposal to
reduce this template boiler-plate. Sometimes that boiler-plate can take
a huge portion of the text of the file and really makes the code hard to
read and frustrating to write. This is of course something that everyone
here has experience from, but is this problem currently going to be
addressed?
--
Kalle Rutanen
http://kaba.hilvi.org
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Thu Apr 12, 2007 4:41 am Post subject: Re: Template classes in C++0x |
|
|
On Apr 12, 1:08 am, REkalleMOunderscoreVErutane...@hotmail.com (Kaba)
wrote:
| Quote: | Consider a template class that has lots of parameters:
template <typename C1, typename C2, typename C3, etc
class A
{
public:
void f();
voif g();
};
Now defining the member functions outside of A, f and g require lots of
code to specify the class around them:
|
What's the point of defining them outside of A since all your code
will have to be in headers anyway?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Nicolas Pavlidis Guest
|
Posted: Thu Apr 12, 2007 3:35 pm Post subject: Re: Template classes in C++0x |
|
|
Mathias Gaunard wrote:
| Quote: | On Apr 12, 1:08 am, REkalleMOunderscoreVErutane...@hotmail.com (Kaba)
wrote:
Consider a template class that has lots of parameters:
template <typename C1, typename C2, typename C3, etc
class A
{
public:
void f();
voif g();
};
Now defining the member functions outside of A, f and g require lots of
code to specify the class around them:
What's the point of defining them outside of A since all your code
will have to be in headers anyway?
|
I think, he menas something like that:
// the header
template<typename Type>
class MyClass
{
//....
};
#include "MyClass.tcpp"
This approach has the advantage that the declaration are sperated from
the definition, and that you can compile the template class, searching
for obious errors (I know that every method of a template - class needs
to be instanziated to find all syntactic erros, but some obious ones can
be found that way too).
The Problem is, that some compilers really want all the code belonging
to a template inside the class - declaration.
For short, this is a (unfortunately not portable) way to have a little
bit of sourcode organisation with templates.
Best regards,
Nicolas
P.S.: I hope I didin't misunderstand your question .
| Quote: | ---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
|
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Vidar Hasfjord Guest
|
Posted: Fri Apr 13, 2007 3:04 pm Post subject: Re: Template classes in C++0x |
|
|
On Apr 12, 12:08 am, REkalleMOunderscoreVErutane...@hotmail.com (Kaba)
wrote:
| Quote: | There clearly is redundancy here. It would be beneficial to group the
definitions to blocks which defines the surrounding class. I know there
has been a proposal to do just this, but I can't quite find it in the
current proposal list.
|
You may be thinking of Carl Daniel's proposal, "Proposed Addition to C+
+: Class Namespaces", N1440.
| Quote: | This is of course something that everyone
here has experience from, but is this problem currently going to be
addressed?
|
I don't think so; at least not in C++09. The proposal is currently
categorized as "No active interest today, but open to resubmit in
future" in the latest "State of C++ Evolution" document (N2169).
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
James Kanze Guest
|
Posted: Fri Apr 13, 2007 6:33 pm Post subject: Re: Template classes in C++0x |
|
|
On Apr 12, 6:41 am, "Mathias Gaunard" <loufo...@gmail.com> wrote:
| Quote: | On Apr 12, 1:08 am, REkalleMOunderscoreVErutane...@hotmail.com (Kaba)
wrote:
Consider a template class that has lots of parameters:
template <typename C1, typename C2, typename C3, etc
class A
{
public:
void f();
voif g();
};
Now defining the member functions outside of A, f and g require lots of
code to specify the class around them:
What's the point of defining them outside of A since all your code
will have to be in headers anyway?
|
First, of course, with a compliant compiler, the code won't have
to be in the headers. And even without a compilant compiler,
readability concerns will probably mean that you want to define
the functions later, and maintainability concerns will probably
mean that you'll define them in a separate file, even if that
file ultimately gets included by your header.
--
James Kanze (GABI Software) email:james.kanze (AT) gmail (DOT) com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Kaba Guest
|
Posted: Fri Apr 13, 2007 10:11 pm Post subject: Re: Template classes in C++0x |
|
|
| Quote: | You may be thinking of Carl Daniel's proposal, "Proposed Addition to C+
+: Class Namespaces", N1440.
|
Yes. Although by clicking the link in the "State of C++ Evolution"
directs you to "C++ Standard Library Active Issues List".
| Quote: | This is of course something that everyone
here has experience from, but is this problem currently going to be
addressed?
I don't think so; at least not in C++09. The proposal is currently
categorized as "No active interest today, but open to resubmit in
future" in the latest "State of C++ Evolution" document (N2169).
|
Well that's unexpected. Because it is only a new notation, it should not
have any effects to other parts of C++ and thus should be trivial to
implement. The reductions on redundant code would be great in some
cases. I see only positive effects, why was it rejected?
--
Kalle Rutanen
http://kaba.hilvi.org
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
James Dennett Guest
|
Posted: Sat Apr 14, 2007 3:02 am Post subject: Re: Template classes in C++0x |
|
|
Kaba wrote:
| Quote: | You may be thinking of Carl Daniel's proposal, "Proposed Addition to C+
+: Class Namespaces", N1440.
Yes. Although by clicking the link in the "State of C++ Evolution"
directs you to "C++ Standard Library Active Issues List".
This is of course something that everyone
here has experience from, but is this problem currently going to be
addressed?
I don't think so; at least not in C++09. The proposal is currently
categorized as "No active interest today, but open to resubmit in
future" in the latest "State of C++ Evolution" document (N2169).
Well that's unexpected. Because it is only a new notation, it should not
have any effects to other parts of C++ and thus should be trivial to
implement. The reductions on redundant code would be great in some
cases. I see only positive effects, why was it rejected?
|
I don't know about rejected, but the most likely reason
for it to be stalled is that nobody has volunteered to
do the work of taking it from a proposal to having
formal wording and a proof-of-concept implementation.
This just means that those who have volunteered their
time and expertise felt that there were more important
things to be working on. If someone additional
volunteers to do the work and champion this proposal,
it could get unstalled -- but it's rather late now to
expect it to make it into C++09.
-- James
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|