www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - stlsoft_sterile_class does not work?

reply pavel <p_ro_te_ct_fromsp_amptolov seznam.cz> writes:
Hi,

The macro 'stlsoft_sterile_class' does not seem to work for me. E.g. 
this code (I carried out everything to a single file, just to have it in 
one piece):
-----cut here-----
#define sterile_class(_cls)     \
   class __m__##_cls { \
    __m__##_cls(){}; \
    ~__m__##_cls(){}; friend class _cls; \
   }; \
   class _cls: public __m__##_cls


sterile_class(sterile_c) {
};

class BadClass : public sterile_c {
};

int main(int argc, char **argv) {
   sterile_c ss;
   BadClass s;
   return 0;
}
-----cut here-----
compiles and runs fine for me (I use mingw 3.2.3). In fact, I do not see 
why this macro *is supposed* to work.

Pavel
Apr 24 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
Argh!

This is one of those things that should have been removed.

Actually it used to work about 10 years ago, when most compilers were that way
inclined.

I remember seeing it in the STLSoft header files last year and thinking I needed
to remove it before someone discovered that it was useless. I will do so
immediately.

Sorry for the waste of time (although I'm sure you've had cause to think about
some inheritance stuff and all that, so hopefully not a complete waste <g>).

Cheers

Matthew

"pavel" <p_ro_te_ct_fromsp_amptolov seznam.cz> wrote in message
news:c6f570$2ssq$1 digitaldaemon.com...
 Hi,

 The macro 'stlsoft_sterile_class' does not seem to work for me. E.g.
 this code (I carried out everything to a single file, just to have it in
 one piece):
 -----cut here-----
 #define sterile_class(_cls)     \
    class __m__##_cls { \
     __m__##_cls(){}; \
     ~__m__##_cls(){}; friend class _cls; \
    }; \
    class _cls: public __m__##_cls


 sterile_class(sterile_c) {
 };

 class BadClass : public sterile_c {
 };

 int main(int argc, char **argv) {
    sterile_c ss;
    BadClass s;
    return 0;
 }
 -----cut here-----
 compiles and runs fine for me (I use mingw 3.2.3). In fact, I do not see
 why this macro *is supposed* to work.

 Pavel

Apr 25 2004
next sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
They're now gone from the code that will be in 1.7.1 (or *another* beta;
hopefully I'm pretty close to 1.7.1 release now).

Once again, sorry for the hassle.

"Matthew" <matthew.hat stlsoft.dot.org> wrote in message
news:c6frd1$sn9$1 digitaldaemon.com...
 Argh!

 This is one of those things that should have been removed.

 Actually it used to work about 10 years ago, when most compilers were that way
 inclined.

 I remember seeing it in the STLSoft header files last year and thinking I

 to remove it before someone discovered that it was useless. I will do so
 immediately.

 Sorry for the waste of time (although I'm sure you've had cause to think about
 some inheritance stuff and all that, so hopefully not a complete waste <g>).

 Cheers

 Matthew

 "pavel" <p_ro_te_ct_fromsp_amptolov seznam.cz> wrote in message
 news:c6f570$2ssq$1 digitaldaemon.com...
 Hi,

 The macro 'stlsoft_sterile_class' does not seem to work for me. E.g.
 this code (I carried out everything to a single file, just to have it in
 one piece):
 -----cut here-----
 #define sterile_class(_cls)     \
    class __m__##_cls { \
     __m__##_cls(){}; \
     ~__m__##_cls(){}; friend class _cls; \
    }; \
    class _cls: public __m__##_cls


 sterile_class(sterile_c) {
 };

 class BadClass : public sterile_c {
 };

 int main(int argc, char **argv) {
    sterile_c ss;
    BadClass s;
    return 0;
 }
 -----cut here-----
 compiles and runs fine for me (I use mingw 3.2.3). In fact, I do not see
 why this macro *is supposed* to work.

 Pavel


Apr 25 2004
prev sibling parent pavel <p_ro_te_ct_fromsp_amptolov seznam.cz> writes:
Thanks Matthew!

No, it wasn't any waste. In fact, when I saw it first, I liked the idea 
of giving such "final classes in C++" and immediately decided to "beat 
it" with a template implementation -- only to find out that the template 
parameter could not be a friend (I wonder why though) and only then that 
the preprocessor implementation did not work either. This all took at 
most 30 minutes alltogether and amused me quite a bit.

Thanks again for all your hard work and finding time to answer
Pavel

Matthew wrote:
 Argh!
 
 This is one of those things that should have been removed.
 
 Actually it used to work about 10 years ago, when most compilers were that way
 inclined.
 
 I remember seeing it in the STLSoft header files last year and thinking I
needed
 to remove it before someone discovered that it was useless. I will do so
 immediately.
 
 Sorry for the waste of time (although I'm sure you've had cause to think about
 some inheritance stuff and all that, so hopefully not a complete waste <g>).
 
 Cheers
 
 Matthew
 
 "pavel" <p_ro_te_ct_fromsp_amptolov seznam.cz> wrote in message
 news:c6f570$2ssq$1 digitaldaemon.com...
 
Hi,

The macro 'stlsoft_sterile_class' does not seem to work for me. E.g.
this code (I carried out everything to a single file, just to have it in
one piece):
-----cut here-----
#define sterile_class(_cls)     \
   class __m__##_cls { \
    __m__##_cls(){}; \
    ~__m__##_cls(){}; friend class _cls; \
   }; \
   class _cls: public __m__##_cls


sterile_class(sterile_c) {
};

class BadClass : public sterile_c {
};

int main(int argc, char **argv) {
   sterile_c ss;
   BadClass s;
   return 0;
}
-----cut here-----
compiles and runs fine for me (I use mingw 3.2.3). In fact, I do not see
why this macro *is supposed* to work.

Pavel


Apr 25 2004