Prev Next error_message_xam.cpp Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
C++: Cppad Swig Exception Handling: Example and Test
# include <cstdio>
# include <string>
# include <cppad/swig/cppad_swig.hpp>

bool error_message_xam(void) {
     using cppad_swig::a_double;
     using cppad_swig::vec_bool;
     using cppad_swig::vec_int;
     using cppad_swig::vec_double;
     using cppad_swig::vec_a_double;
     using cppad_swig::a_fun;
     using cppad_swig::sparse_rc;
     using cppad_swig::sparse_rcv;
     using cppad_swig::sparse_jac_work;
     using cppad_swig::sparse_hes_work;
     using std::string;
     //
     // initialize return variable
     bool ok = true;
     //------------------------------------------------------------------------
     ok = false;
     try {
          cppad_swig::error_message("test message");
     } catch (...) {
          string stored_message = cppad_swig::error_message("");
          ok = stored_message == "test message";
     }
     return( ok  );
}

Input File: build/lib/example/cplusplus/error_message_xam.cpp