www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Changes to boost::any and new home for this libary


I have prepared updated implementation of boost::any.

You can find it at:

Changes from boost version (implementation has been changed also from fist
version announced here):

1. You can not construct Any type with specific value as parameter of
constructor as there is no templatized constructors in D. I used instead
static opCall operator as a factory for Any objects. You can use it as
 auto v1=Any(5);
 auto v2=Any("Text"[]);
 auto v3=Any(); // empty Any

 You can also use method assign:
 auto v4=(new Any).assign(78);
 auto v5=(new Any).assign("Other text"[]);

2. There is no any_cast function. Instead of this function Any has a member
templated function as!(type)(): 
 auto v=Any(5);
 int i=v.as!(int);

3. There is no bad_any_cast exception. Instead I used assertion in member
function "as", which is triggered in case of bad casting of Any value.


You can get Any from:

You need at least DMD 0.177 to compile Any (due to opAssign and linking
errors in earlier compilers).

At the moment project is not visible on "Projects" page. Also forum doesn't
work. You have to use above link directly.

In SVN directory "downloads" is zip file with source files for
ProgramOptions and Any.

Marcin Kuszczak (Aarti_pl)
Ask me why I believe in Jesus 
http://zapytaj.dlajezusa.pl (en/pl)
Dec 19 2006