Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Full documentation is on boost site: http://boost.org/doc/html/any.html - with below modifications:

  1. You can not construct Any type with specific value as parameter of constructor.

Because of that I used static opCall operator as a factory for Any objects. You can use it as below:

 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"[]);
  1. There is no any_cast function. Instead of this function Any has a member templated function as:
 auto v=Any(5);
 int i=v.as!(int);
  1. 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.