Discussion Locked

Consistency in do_if/assign_if functions

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
The Nov. 25, C++ TechMail discusses '_if' counterparts in the Standard Template Library (STL). How do you handle the inconsistent use of '_if' counterparts in STL? Will this tip help you in your future C++ programming?

2 replies

by Mark W. Kaelin

I received this suggestion in an e-mail.

Instead of:

int aTest[] = { 3, 6, 1, 30, 4, 7, 20, 3, 34, 2, 66 };
int nCount = sizeof( aTest) / sizeof( int);

do:

int aTest[] = { 3, 6, 1, 30, 4, 7, 20, 3, 34, 2, 66 };
int nCount = sizeof( aTest) / sizeof( aTest[0]);

You remove the type dependence.

Anyone care to comment?

by john torjo

Hi,

Thanks for pointing it out!
I usually do it exacly the way you said it. Being just an example, I must have forgotten... I'll be more careful in the future.

Best,
John

This discussion is closed to new replies.