Re: Unique Integer Types -- a useful C++ trick
From: Asfand Yar Qazi (see_at_message.body.com)
Date: 11/20/04
- Next message: Michael Post: "Re: ftp-connection under dos6.2"
- Previous message: Thomas Matthews: "Re: ftp-connection under dos6.2"
- In reply to: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Next in thread: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Reply: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Nov 2004 19:16:26 +0000
>
> The trouble is you lose the constructor taking an unsigned int and the private
> constructor taking a bool. If you don't mind macros, you could do
>
> #define UNIQUE_INT(name) \
> struct name : unique_int<name> { \
> private: name(bool); \
> public: name(unsigned v = 0u) : unique_int<name>(v) { }\
> }; \
> /**/
>
> UNIQUE_INT(set_num_t)
> UNIQUE_INT(entry_num_t)
> UNIQUE_INT(lru_entry_t)
>
Macros are cool. It would have been great if Bjarne had improved the
preprocessor as well when he invented the C++ language... perhaps it
is still possible with the new C++ standard coming up?
-- http://www.it-is-truth.org/
- Next message: Michael Post: "Re: ftp-connection under dos6.2"
- Previous message: Thomas Matthews: "Re: ftp-connection under dos6.2"
- In reply to: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Next in thread: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Reply: Jonathan Turkanis: "Re: Unique Integer Types -- a useful C++ trick"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|