Boost logo

Boost :

From: Jason Shirk (jasonsh_at_[hidden])
Date: 2002-01-28 21:24:35


Unfortunately, it's the compiler, and it has nothing to do with template
template parameters.

The compiler is improperly instantiating BOOST_STATIC_ASSERT (actually
STATIC_ASSERTION_FAILURE) when the expression depends on a non-type
parameter in a less than trivial way (like T::N, for example.)

I haven't come up with a workaround. Perhaps those more adept at
finding workarounds could offer a suggestion.

Fortunately for me, this problem doesn't reproduce in future builds of
VC.

Jason Shirk
VC++ Compiler Team

> -----Original Message-----
> From: davidbrownell98006 [mailto:david_brownell_at_[hidden]]
> Sent: Monday, January 28, 2002 5:20 PM
> To: boost_at_[hidden]
> Subject: [boost] BOOST_STATIC_ASSERT and template template parameters
>
> I am trying to use BOOST_STATIC_ASSERT, but I think that my problem
> is either with my compiler (VC 7.0 - aka VS.NET) or my understanding
> of template template parameters. I would like the following code to
> compile without errors. The code is pretty straight forward, so I
> will just post it rather than trying to explain it in plain English.
>
> Thanks in advance for your help, and please be gentle if this is
> simply a stupid question :)
>
> David Brownell
>
> //////////////////////////////////////////////////////////////
> //////////////////////////////////////////////////////////////
>
> #include "boost\static_assert.hpp"
>
> #define COMPILE_LESS_DESIRABLE_CODE 1
>
> template <unsigned int Number>
> struct Size
> {
> enum { SIZE = Number };
> };
>
> template <
> class SizeClass,
> template <class> class APolicy
> >
> struct AClass : public APolicy<SizeClass>
> {
> };
>
> template <class SizeClass>
> struct PolicyNumber1
> {
> #if COMPILE_LESS_DESIRABLE_CODE
> enum { SizeClassSize = SizeClass::SIZE };
> BOOST_STATIC_ASSERT(SizeClassSize == 1);
> #else //COMPILE_LESS_DESIRABLE_CODE
> BOOST_STATIC_ASSERT(SizeClass::SIZE == 1);
> #endif //COMPILE_LESS_DESIRABLE_CODE
> };
>
> template <class SizeClass>
> struct PolicyNumber2
> {
> #if COMPILE_LESS_DESIRABLE_CODE
> enum { SizeClassSize = SizeClass::SIZE };
> BOOST_STATIC_ASSERT(SizeClassSize == 2);
> #else //COMPILE_LESS_DESIRABLE_CODE
> BOOST_STATIC_ASSERT(SizeClass::SIZE == 2);
> #endif //COMPILE_LESS_DESIRABLE_CODE
> };
>
> int main(void)
> {
> AClass<Size<1>, PolicyNumber1> c1;
> AClass<Size<2>, PolicyNumber2> c2;
> return(true);
> }
>
>
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-
> unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk