| View previous topic :: View next topic |
| Author |
Message |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Wed Dec 30, 2009 3:42 pm Post subject: |
|
|
| Flyte wrote: |
| Code: | template <typename T, unsigned int N>
const unsigned int lengthof(const T(&)[N]) {
return N;
} |
|
Thanks for that lenghtof() thing
I was always using sizeof(array) / sizeof( typename ) but this looks way better. Where do you find these kinds of snippets? Or did you make this yourself?
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Dec 30, 2009 3:54 pm Post subject: |
|
|
| tombana wrote: | Thanks for that lenghtof() thing
I was always using sizeof(array) / sizeof( typename ) but this looks way better. Where do you find these kinds of snippets? Or did you make this yourself? |
No problem. I made this myself, but it certainly isn't the only variation. Template meta-programming is very cool, and allows you to do some very powerful things with the language.
Once you master the semantics of the language, thinking up stuff like this is extremely trivial.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 6:00 pm Post subject: |
|
|
| Flyte wrote: | | tombana wrote: | Thanks for that lenghtof() thing
I was always using sizeof(array) / sizeof( typename ) but this looks way better. Where do you find these kinds of snippets? Or did you make this yourself? |
No problem. I made this myself, but it certainly isn't the only variation. Template meta-programming is very cool, and allows you to do some very powerful things with the language.
Once you master the semantics of the language, thinking up stuff like this is extremely trivial. |
_countof is also extremely trivial. I would hope something this simple would be obvious.
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 6:27 pm Post subject: |
|
|
| Slugsnack wrote: | | _countof is also extremely trivial. I would hope something this simple would be obvious. |
_countof is also a vendor specific extension, which makes it useless junk.
I am touched that you spent the last 4 days trying to think of a way to contradict me, though. You have yet again failed to mock someone more intelligent than you, perhaps it's time to give up?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 6:34 pm Post subject: |
|
|
| Flyte wrote: | | Slugsnack wrote: | | _countof is also extremely trivial. I would hope something this simple would be obvious. |
_countof is also a vendor specific extension, which makes it useless junk.
I am touched that you spent the last 4 days trying to think of a way to contradict me, though. You have yet again failed to mock someone more intelligent than you, perhaps it's time to give up? |
| Code: | #if !defined(_countof)
#if !defined(__cplusplus)
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#else
extern "C++"
{
template <typename _CountofType, size_t _SizeOfArray>
char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
#define _countof(_Array) sizeof(*__countof_helper(_Array))
}
#endif
#endif |
But oh no, the almighty Flyte with his robust code, stack of PDFs and his essentially being paid to go to university does not like #define
For you: http://web.ebscohost.com/ehost/pdf?vid=2&hid=7&sid=0583ebe2-8f64-4a5d-b671-6d7f903956ff@sessionmgr11
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 6:47 pm Post subject: |
|
|
| Slugsnack wrote: | | But oh no, the almighty Flyte with his robust code, stack of PDFs and his essentially being paid to go to university does not like #define |
Slugsnack, I honestly think you should go see a psychiatrist. You seemed to be absolutely enamored with me as can be seen from you consistently quoting me and following me around.
You're sort of like a beat dog that just won't stop coming back to his master. It's both hilarious and absolutely pathetic. You should just give up.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 7:00 pm Post subject: |
|
|
| Flyte wrote: | | Slugsnack wrote: | | But oh no, the almighty Flyte with his robust code, stack of PDFs and his essentially being paid to go to university does not like #define |
Slugsnack, I honestly think you should go see a psychiatrist. You seemed to be absolutely enamored with me as can be seen from you consistently quoting me and following me around.
You're sort of like a beat dog that just won't stop coming back to his master. It's both hilarious and absolutely pathetic. You should just give up. |
Firstly nice ad hominem, secondly good job following x0r's approach at debating with me.
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 7:13 pm Post subject: |
|
|
| Slugsnack wrote: | | Firstly nice ad hominem, secondly good job following x0r's approach at debating with me. |
Your entire approach has been:
- Mock.
- Repeat 1 until successful.
Not once have you contributed anything intelligent.
Every single reply you make to me includes some form of quote in an attempt to mock me. It's both juvenile and extremely pathetic. The best course of action for you is to stop arguing with people far above your skill level in a futile attempt to gain some e-fame.
I honestly think there is something wrong with you, go see a psychiatrist. Don't expect a reply from me, I'm going to wean you off of my presence, since you seem to require it to function.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 8:09 pm Post subject: |
|
|
| Flyte wrote: | | Slugsnack wrote: | | Firstly nice ad hominem, secondly good job following x0r's approach at debating with me. |
Your entire approach has been:
- Mock.
- Repeat 1 until successful.
Not once have you contributed anything intelligent.
Every single reply you make to me includes some form of quote in an attempt to mock me. It's both juvenile and extremely pathetic. The best course of action for you is to stop arguing with people far above your skill level in a futile attempt to gain some e-fame.
I honestly think there is something wrong with you, go see a psychiatrist. Don't expect a reply from me, I'm going to wean you off of my presence, since you seem to require it to function. |
You see, the thing is that I do help people. Perhaps you can challenge the level of intelligence I display whilst I do it. However the truth of the matter is that I do help people and I do help them solve their problems.
You, on the other hand, jump into threads critiquing others' efforts with your little stack of PDFs. Occasionally you will contribute your 'help' in the form of irrelevant and snide comments. In the rare occasions when you actually contribute code, it is often at a level way past anything that could possibly help the poster learn. Most likely you are putting them off instead.
There are two types of teachers. The good ones will realise that each person requires a different style to learn and will try to tender their own style to that of the student. The shit ones will flaunt their own knowledge by spouting their knowledge on the most advanced topics they can associate with a given question.
You have no interest in teaching, just showing off and being a dick. You put people down or make comments in a negative or asshole way for the sake of being a dick.
|
|
| Back to top |
|
 |
|