Using C++ to invoke the block safely