Question: I'm trying to select all jobs that a user has been added to, but exclude jobs that they have declined. I've been looking into NOT EXISTS, but I haven't been able to exclude declined jobs with that.

Table: declined

```
+---------+---------+---------+----------+
|      id |  job_id | user_id | declined |
+---------+---------+---------+----------+
|      15 |     223 |      25 |        1 |
|     100 |     156 |      50 |        1 |
|     125 |     651 |      60 |        1 |
+---------+---------+---------+----------+

```

Current query. Selects all jobs they've been added to, as well as jobs they have declined.

```
SELECT
    job.*, applicants.*, declined.*
FROM job
    JOIN applicants ON job.job_id = applicants.job_id
    LEFT OUTER JOIN declined ON job.job_id = declined.job_id
WHERE applicants.user_id = '" .  $userId . "' AND applicants.recruited = 1

```

Failed attempt. This obviously does not select any records.

```
SELECT
    job.*, applicants.*, declined.*
FROM job
    JOIN applicants ON job.job_id = applicants.job_id
    LEFT OUTER JOIN declined ON job.job_id = declined.job_id
WHERE applicants.user_id = '" .  $userId . "' AND applicants.recruited = 1 AND declined.declined = 0

```

Answer: 
Default constructor of optional is declared `noexcept`, as per <http://en.cppreference.com/w/cpp/experimental/optional/optional>.
You're constructing an `optional<T>` from a value of T (probably a `T&&`), which in turn calls the corresponding ctor of T. If T's ctor throws, then so does optional's ctor. Depending upon what the missing code inside the `try{}` block does, your exception specification should be something like

```
noexcept(std::is_nothrow_move_constructible<T>::value)

```

or

```
noexcept(std::is_nothrow_constructible<T>::value)

```