This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: How to get more info about 'bad_function_call' ?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Linda A. Walsh" <gcc at tlinx dot org>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 27 Jan 2015 15:43:29 +0000
- Subject: Re: How to get more info about 'bad_function_call' ?
- Authentication-results: sourceware.org; auth=none
- References: <54C7A9F8 dot 70504 at tlinx dot org> <CAH6eHdQemyPo80Kq4g-tGvyqqvFrUP4jtPOLr8wyz_rAwfk__A at mail dot gmail dot com>
On 27 January 2015 at 15:42, Jonathan Wakely wrote:
> On 27 January 2015 at 15:08, Linda A. Walsh wrote:
>> How can I check the validity of what I am about to call and find
>> out what is wrong with it before I make the call and am terminated?
>
> By doing exactly that. Check if the std::function you're calling is
> valid, e.g. if (f) or if (f == nullptr) or if (!!f) or whatever floats
> your boat.
The second one should be (f != nullptr) to be consistent with the
other two examples.
The point is you test it like you'd test a plain function pointer.