/*
Pavel Vozenilek <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I use Borland C++ Builder 6, update 4, STLPort 4.5.1 (provided by Borland)
> and Boost is 1.30.0beta1.
>

Sorry for the delay...

> Following snippet of code fails:
>
> -----------------
> #include <boost/optional.hpp>
> #include <utility>
>
> void foo(const boost::optional<std::pair<unsigned, unsigned> >& aux =
>     boost::optional<std::pair<unsigned, unsigned> >())
> {}
>
> int main() {}
> -----------------
>
> with error message:
> [C++ Error] Unit1.cpp(12): E2188 Expression syntax
> [C++ Error] Unit1.cpp(12): E2299 Cannot generate template specialization
> from '_STLD::pair<_T1,_T2>'
> [C++ Error] Unit1.cpp(12): E2299 Cannot generate template specialization
> from 'boost::optional<T>'
> [C++ Error] Unit1.cpp(13): E2257 , expected
> [C++ Error] Unit1.cpp(33): E2151 Type mismatch in default value for
> parameter 'aux'
> [C++ Error] Unit1.cpp(12): E2293 ) expected
>
>
> The same code compiles OK with Intel C++ 7.0.
>
> If I use typedef it works OK with both BC++B and Intel C++:
> -----------------
> #include <boost/optional.hpp>
> #include <utility>
>
> typedef boost::optional<std::pair<unsigned, unsigned> > AType;
>
> void foo(AType  aux = AType())
> {}
>
> int main() {}
> -----------------
>
Hmm..
I can't reproduce the problem here with the 1.30.0 release,
BCB6, update 4, from within the IDE.
Which command line options are you using?


>
> Borland also fails with this construct:
> -----------------
> #include <boost/optional.hpp>
>
> int main()
> {
>   boost::optional<int> aux(0);
>   if (aux && *aux == 0) {
>     aux.reset(1);
>   }
> }
> -----------------
>
> with this error message:
> [C++ Error] Unit1.cpp(24): E2094 'operator&&' not implemented in type
> 'boost::optional<int>' for arguments of type 'bool'
>
> Intel C++ 7.0 compiles and executes this snippet OK.
>
> This works in BC++B:
> -----------------
> #include <boost/optional.hpp>
>
> int main()
> {
>   boost::optional<int> aux(0);
>   if ((!!aux) && *aux == 0) {
>     aux.reset(1);
>   }
> }
> -----------------
>
This one is a known Bortland bug.
In fact, operator!() is provided precisely in order
to allow the second form (with !!) to be used when
needed.
In Borland, the safe_bool operators works only if
the optional is the only element in the boolean
expression, as in:  if ( aux ) ...

Thanks for the report!

Fernando Cacciola




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to