Skip to content

Commit

Permalink
gsl/narrow should include <exception> (#1044)
Browse files Browse the repository at this point in the history
This file uses std::exception, so it should include the appropriate header.

Normally it gets the STL's <exception> header included via the gsl/assert file, but this is skipped with _HAS_EXCEPTIONS=0. I understand _HAS_EXCEPTIONS is undocumented and unsupported, but regardless, the appropriate header should be included here.

Alternatively, gsl/narrow should be modified to support _HAS_EXCEPTIONS=0, like gsl/assert was. But I'm not proposing that change. <exception> does define std::exception even with _HAS_EXCEPTIONS=0.
  • Loading branch information
TheJCAB committed Apr 26, 2022
1 parent 2bfd495 commit f21f29d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/gsl/narrow
Expand Up @@ -16,8 +16,9 @@

#ifndef GSL_NARROW_H
#define GSL_NARROW_H
#include "assert" // for Expects
#include "util" // for narrow_cast
#include "assert" // for Expects
#include "util" // for narrow_cast
#include <exception> // for std::exception
namespace gsl
{
struct narrowing_error : public std::exception
Expand Down

0 comments on commit f21f29d

Please sign in to comment.