====== Xfor_cast ======= // var1 type : const TypeName& // var2 type : AnyPtr Xfor_cast(var, target) Xforと同機能ですが、イテレータ変数の型を指定することが出来ます。 また、else節をつなげることが出来、キャストに失敗した場合はその都度else節を実行します。 ===== Example ===== ==== C++ ==== void exec_xtal(){ ArrayPtr array(xnew(5)); array->set_at(0, 1); array->set_at(1, "foo"); array->set_at(2, 2); array->set_at(3, "bar"); array->set_at(4, 3); Xfor_cast(const StringPtr& it, array){ it->p(); } else { StringPtr("cast failed")->p(); } } ==== Xtal ==== array : [1, "foo", 2, "bar", 3]; array{ if (it.class === String){ it.p; } else { "cast failed".p; } } ==== Output ==== cast failed foo cast failed bar cast failed