$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Jim.Hyslop (jim.hyslop_at_[hidden])
Date: 2001-10-19 11:44:24
rajanikanth jammalamadaka [SMTP:rajanik3_at_[hidden]] wrote:
> Hi! Jim,
> Could you please tell me why this code is not working:
>
> #include <iostream>
> #include <boost/any.hpp>
> using namespace boost;
> int main()
> {
>
> any holdsanything ;
> holdsanything = 9;
> std::cout<<holdsanything<<endl;
> holdsanything = std::string("hello");
> std::cout<<holdsanything<<endl;
> return 0;
> }
Hi, Raj
You didn't specify what problems you were having. Am I correct in assuming
you get a compiler error on the std::cout lines? If so, then the problem is
that class 'any' does not have an extraction operator defined. If you change
the lines to:
std::cout << any_cast<int>(holdsanything)<<std::endl;
and
std::cout << any_cast<const char *>(holdsanything) << std::endl;
it should work properly.
-- Jim