 |
|
|
 |
|
 |
However, visual c++ provides another way of reusing your code.
In fact templates are a standard C++ language feature, and VC is one of the worst compilers in terms of only partial implimentation, and that not fully standards compliant. That should change soon with a SP for .NET.
Secondly, your container classes have no variables. The variables are kind of the point of template based programming, don't you think ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
Christian Graus wrote:
Secondly, your container classes have no variables. The variables are kind of the point of template based programming, don't you think ?
Let's not forget types. binary_function for instance doesn't define any data, only types. I agree that it is not a container, but it is template based programming.
I really dig the type magic you can do with templates. A really cool thing is std::allocator<T1>::rebind<T2>::other. Imagine a "normal" container, i.e. a std::list. It knows how to allocate chunks of memory for T since it is specified as a template argument. But how do you allocate the actual list nodes (which contain next and prev pointers)? Thats where the rebind<T>::other comes in to play.
template<class U>
struct rebind {
typedef allocator<U> other;
};
So when the STL implementation of list allocates a node, it does something like this:
template <typename T, typename A = allocator<T> >
struct list
{
struct node
{
T d;
node* prev;
node* next;
};
typedef A::rebind<node>::other A_node;
A_node node_alloc;
void push_back(const T& t)
{
node* new_node = node_alloc.allocate(1, NULL);
}
};
Voila! The user of the list cannot specify an allocator of nodes, since the user should not be aware of its existance - it's an implementation detail of list. The list however must know how to allocate memory using the users allocation specifications, but it cannot do that "straight out of the box" - it was only given an allocator for T which is the user type to be contained in each node. The solution is simple and elegant: a pseudo recursive template called rebind.
The more I read and write template code, the more I fall in love with it. When's .NET going to support template code generation so that I can also fully enjoy it?
Sonorked as well: 100.13197 jorgen
FreeBSD is sexy.
|
|
|
|
 |
|
 |
Jörgen Sigvardsson wrote:
When's .NET going to support template code generation so that I can also fully enjoy it?
By the middle of the year, I believe.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
However, visual c++ provides another way of reusing your code.
In fact templates are a standard C++ language feature, and VC is one of the worst compilers in terms of only partial implimentation, and that not fully standards compliant. That should change soon with a SP for .NET.
Secondly, your container classes have no variables.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
Christian Graus wrote:
That should change soon with a SP for .NET
Has MS changed its policy on SP?
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan.
|
|
|
|
 |
|
 |
sp = service pack. What policy ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
Huh, I thought you knew. SP is for bug fixes, no knew features. The main reason why we have to put up with useless STL in VC++ 6.0, even though the author released a new and better version. Just take another look at the SP1-SP4 of VS 6.0 and see if any introduced a new feature.
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan.
|
|
|
|
 |
|
 |
I was under the impression that the STL has been static due to legal issues for M$ with Dinkumware. The previous service packs fixed some template behaviour, but I know for sure that they have promised we are getting pts mid of this year, I presumed it would be a SP, maybe they will call it something else.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
Actually, it was due to a lawsuit that P.J. Plauger had with his publisher at the time, Plum Hall. My understanding was that because of the legal issues, Microsoft wasn't going to update his code until after that was all cleared up. He won the lawsuit in July, 1998 and the final settlment with Plum Hall was in May, 2000. For a more complete story, you can check out his site (http://www.dinkumware.com/hot_news.html).
Soooooooo, that leaves the question of why it's taken this long to get an update to the STL. I've no idea on that. From what I understand (I've not looked it up yet to verify) is that VS.NET has the newer STL code.
Regards,
Mike
|
|
|
|
 |
|
 |
you had 3 from 7--->21 points
now 2.5 from 10--->25
Means from the last 3 votes you got 4 points...
211 or 121 or 112 are the possibilites
Nish
p.s. you are lucky man, one of them at least gave you a 2
I am looking for a free racing game. Old style racing game without any complicated 3D stuff. Around 4 MB download. If anyone has such a game, please inform me.
|
|
|
|
 |
|
 |
Nish, you've got too much time on your hands. You're tracking articles for votes now ? I thought your dad was visiting ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
CG :- "I thought your dad was visiting ?"
Nish :- Yeah, he came yesterday, we went out yesterday evening. Thats why I was missing.
He was to leave only tomorrow, but he left today due to some urgent work
Nish
I am looking for a free racing game. Old style racing game without any complicated 3D stuff. Around 4 MB download. If anyone has such a game, please inform me.
|
|
|
|
 |
|
 |
The car example is awful. This would be done by using a base class, which would allow for a container of cars that could all have their common methods called by a functor. Your example allows the user to call the car methods on an int, or a CString, or a CWnd, or any other non-related type. Type safety is important, and the base class method would provide it.
Which leads to my other comment - containers are an obvious way of illustrating templates, but you should also clarify that no-one in their right mind writes their own generic containers unless they have first made sure they have a need the STL does not address.
Also the int example for using CMyArray is missing the template argument.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
Hi CG
I have been analyzing ratings since yesterday.
As James mentioned elsewhere I am skipping the lounge for a couple of days to relax a little.
I have noticed some funny ratings. But in this particular article's case, some of the ratings are valid in the sense this article wont be more than a 3.
I give some people a 5 just for giving them a boost.
Now I am thinking give some 1s too, just to balance things...
Of course this whole thing is crazy really...
Instead of votes we can simply have the posts below which are far more indicative of problems usually though even there, some anonymous clown might come and say in two words "article sucks" and go without explaining why he thinks so.
Nish
I am looking for a free racing game. Old style racing game without any complicated 3D stuff. Around 4 MB download. If anyone has such a game, please inform me.
|
|
|
|
 |
|
 |
I've lost my 'quote' button, but I agree - the rating is pretty meaningless except as a ballpark. My articles that were given a 1 both went down a lot, and the better of the two is at 4.56, because the odd bad rating gets ironed out by the average. But my most successful article IMO is the one on functors, because although it has an average rating, it has generated a lot of discussion, not all in my favour, but all intelligent and valid.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
 |
|
 |
int SetSize(); <----
usually it is void/int SetSize(int);
Nish
p.s. 21 total [7 * 3 ]... Not bad really
I am looking for a free racing game. Old style racing game without any complicated 3D stuff. Around 4 MB download. If anyone has such a game, please inform me.
|
|
|
|
 |
|
 |
free game:
1. Start Excel 2000
2. Select "Save as web page" from File menu.
3. Select "Save: Selection: Sheet"
4. Check "Add interactivity" and click Save.
5. Close Excel.
6. Open saved file in IE 4/5.
7. Go to line 2000 and column WC.
8. Select line 2000 and and goto to collumn WC by presing Tab key.
9. Press Shift-Ctrl-Alt and click on the icon in upper left corner of this sheet.
10. Enjoy your ride
soptest
|
|
|
|
 |
|
 |
soptest wrote:
The game for baby
baby who???
Nish
I am looking for a free racing game. Old style racing game without any complicated 3D stuff. Around 4 MB download. If anyone has such a game, please inform me.
|
|
|
|
 |
|
 |
Do you like that game?
soptest
|
|
|
|
 |