This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to get more info about 'bad_function_call' ?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 27/01/2015 16:08, Linda A. Walsh wrote:
> I have prog that terminates: terminate called after throwing an
> instance of 'std::bad_function_call' what():  bad_function_call 
> Aborted (core dumped).
> 
> on about the 8th call using it.  If it was a simple indirect
> function pointer, I could, *possibly*, check to see if it was Null
> before the call or had an address outside of my program area, but
> it's not, and trying to coerce it into something to check hasn't
> been straightforward.

To me it looks like what you want is function::operator bool. If you
have an std::function named f, you can check if it's safe to call with
a simple

if(f) f(); else { /*unsafe to call*/ }

http://www.cplusplus.com/reference/functional/function/operator_bool/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iF4EAREIAAYFAlTHsDMACgkQbTKLH9en/LuUXQD9G4121+W1AakQcTb6jLxjuT+C
1mGDMRreuWbqLGoKzsoA+wYk5tv4pfqVl3wu7lya7CdE2YD4MVttO1k7fKYgshyL
=D7n0
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]