Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-05-13 13:25:51


Please don't top post ... reordered.

>
> VC6 is pretty strange, I agree. In particular, it doesn't handle
> functions with non-type template parameters well. The following code
> should demonstrate the problem. (Hopefully I'm remembering the problem
> correctly -- I don't have VC6 installed on this machine.)
>
> template<int I> void foo() { std::cout << I << '\n'; }
>
> int main() {
> foo<1>();
> foo<2>();
> return 0;
> }
>
> If you must use VC6, avoid non-type template parameters for function
> templates.
>
>

Sliwa, Przemyslaw (London) wrote:
> This returns in both cases the same value.
> Is there a way around this problem at all?
>
> Thanks
>
> Pshemek
>

Try using integer wrappers. The MPL ones should do the trick:

template<typename Int> void foo()
   { std::cout << Int::value << '\n'; }

int main() {
   foo<mpl::int_<1> >();
   foo<mpl::int_<2> >();
   return 0;
}

The original problem was using bools as a non-type template parameter,
so the fix would be to use mpl::true_ and mpl::false_.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net