Add noexcept to various constructors related to graphs.

* m4/gccwarn.m4: Enable -Wnoexcept.
* src/graph/graph.hh, src/twa/acc.hh, src/twa/twagraph.hh: Add noexcept
to various constructors.
This commit is contained in:
Alexandre Duret-Lutz 2015-10-02 11:47:21 +02:00
parent 20365e53f0
commit 54935cb9c7
4 changed files with 34 additions and 23 deletions

View file

@ -33,7 +33,8 @@ EOF
Wwrite-strings \ Wwrite-strings \
Wcast-qual \ Wcast-qual \
Wdocumentation \ Wdocumentation \
Wmissing-declarations Wmissing-declarations \
Wnoexcept
do do
CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$cf_opt" CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$cf_opt"
if AC_TRY_EVAL(ac_compile); then if AC_TRY_EVAL(ac_compile); then

View file

@ -27,6 +27,7 @@
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <type_traits>
namespace spot namespace spot
{ {
@ -64,14 +65,16 @@ namespace spot
template <typename... Args, template <typename... Args,
typename = typename std::enable_if< typename = typename std::enable_if<
!first_is_base_of<boxed_label, Args...>::value>::type> !first_is_base_of<boxed_label, Args...>::value>::type>
boxed_label(Args&&... args): boxed_label(Args&&... args)
label{std::forward<Args>(args)...} noexcept(std::is_nothrow_constructible<Data, Args...>::value)
: label{std::forward<Args>(args)...}
{ {
} }
// if Data is a POD type, G++ 4.8.2 wants default values for all // if Data is a POD type, G++ 4.8.2 wants default values for all
// label fields unless we define this default constructor here. // label fields unless we define this default constructor here.
explicit boxed_label() explicit boxed_label()
noexcept(std::is_nothrow_constructible<Data>::value)
{ {
} }
@ -115,14 +118,16 @@ namespace spot
template <typename... Args, template <typename... Args,
typename = typename std::enable_if< typename = typename std::enable_if<
!first_is_base_of<boxed_label, Args...>::value>::type> !first_is_base_of<boxed_label, Args...>::value>::type>
boxed_label(Args&&... args): boxed_label(Args&&... args)
Data{std::forward<Args>(args)...} noexcept(std::is_nothrow_constructible<Data, Args...>::value)
: Data{std::forward<Args>(args)...}
{ {
} }
// if Data is a POD type, G++ 4.8.2 wants default values for all // if Data is a POD type, G++ 4.8.2 wants default values for all
// label fields unless we define this default constructor here. // label fields unless we define this default constructor here.
explicit boxed_label() explicit boxed_label()
noexcept(std::is_nothrow_constructible<Data>::value)
{ {
} }
@ -154,8 +159,9 @@ namespace spot
template <typename... Args, template <typename... Args,
typename = typename std::enable_if< typename = typename std::enable_if<
!first_is_base_of<distate_storage, Args...>::value>::type> !first_is_base_of<distate_storage, Args...>::value>::type>
distate_storage(Args&&... args): distate_storage(Args&&... args)
State_Data{std::forward<Args>(args)...} noexcept(std::is_nothrow_constructible<State_Data, Args...>::value)
: State_Data{std::forward<Args>(args)...}
{ {
} }
}; };
@ -178,6 +184,7 @@ namespace spot
StateIn src; // source StateIn src; // source
explicit edge_storage() explicit edge_storage()
noexcept(std::is_nothrow_constructible<Edge_Data>::value)
: Edge_Data{} : Edge_Data{}
{ {
} }
@ -185,6 +192,9 @@ namespace spot
template <typename... Args> template <typename... Args>
edge_storage(StateOut dst, Edge next_succ, edge_storage(StateOut dst, Edge next_succ,
StateIn src, Args&&... args) StateIn src, Args&&... args)
noexcept(std::is_nothrow_constructible<Edge_Data, Args...>::value
&& std::is_nothrow_constructible<StateOut, StateOut>::value
&& std::is_nothrow_constructible<Edge, Edge>::value)
: Edge_Data{std::forward<Args>(args)...}, : Edge_Data{std::forward<Args>(args)...},
dst(dst), next_succ(next_succ), src(src) dst(dst), next_succ(next_succ), src(src)
{ {
@ -238,12 +248,13 @@ namespace spot
public: public:
typedef typename Graph::edge edge; typedef typename Graph::edge edge;
edge_iterator() edge_iterator() noexcept
: g_(nullptr), t_(0) : g_(nullptr), t_(0)
{ {
} }
edge_iterator(Graph* g, edge t): g_(g), t_(t) edge_iterator(Graph* g, edge t) noexcept
: g_(g), t_(t)
{ {
} }
@ -305,8 +316,8 @@ namespace spot
typedef typename Graph::state_storage_t state_storage_t; typedef typename Graph::state_storage_t state_storage_t;
typedef typename Graph::edge edge; typedef typename Graph::edge edge;
killer_edge_iterator(Graph* g, edge t, state_storage_t& src): killer_edge_iterator(Graph* g, edge t, state_storage_t& src) noexcept
super(g, t), src_(src), prev_(0) : super(g, t), src_(src), prev_(0)
{ {
} }
@ -371,8 +382,8 @@ namespace spot
{ {
public: public:
typedef typename Graph::edge edge; typedef typename Graph::edge edge;
state_out(Graph* g, edge t): state_out(Graph* g, edge t) noexcept
g_(g), t_(t) : g_(g), t_(t)
{ {
} }
@ -433,13 +444,13 @@ namespace spot
} }
public: public:
all_edge_iterator(unsigned pos, tv_t& tv) all_edge_iterator(unsigned pos, tv_t& tv) noexcept
: t_(pos), tv_(tv) : t_(pos), tv_(tv)
{ {
skip_(); skip_();
} }
all_edge_iterator(tv_t& tv) all_edge_iterator(tv_t& tv) noexcept
: t_(tv.size()), tv_(tv) : t_(tv.size()), tv_(tv)
{ {
} }
@ -492,7 +503,7 @@ namespace spot
tv_t& tv_; tv_t& tv_;
public: public:
all_trans(tv_t& tv) all_trans(tv_t& tv) noexcept
: tv_(tv) : tv_(tv)
{ {
} }

View file

@ -38,20 +38,20 @@ namespace spot
mark_t() = default; mark_t() = default;
mark_t(value_t id) mark_t(value_t id) noexcept
: id(id) : id(id)
{ {
} }
template<class iterator> template<class iterator>
mark_t(const iterator& begin, const iterator& end) mark_t(const iterator& begin, const iterator& end) noexcept
{ {
id = 0U; id = 0U;
for (iterator i = begin; i != end; ++i) for (iterator i = begin; i != end; ++i)
set(*i); set(*i);
} }
mark_t(std::initializer_list<unsigned> vals) mark_t(std::initializer_list<unsigned> vals) noexcept
: mark_t(vals.begin(), vals.end()) : mark_t(vals.begin(), vals.end())
{ {
} }

View file

@ -34,8 +34,7 @@ namespace spot
struct SPOT_API twa_graph_state: public spot::state struct SPOT_API twa_graph_state: public spot::state
{ {
public: public:
twa_graph_state(): twa_graph_state() noexcept
spot::state()
{ {
} }
@ -78,12 +77,12 @@ namespace spot
bdd cond; bdd cond;
acc_cond::mark_t acc; acc_cond::mark_t acc;
explicit twa_graph_edge_data() explicit twa_graph_edge_data() noexcept
: cond(bddfalse), acc(0) : cond(bddfalse), acc(0)
{ {
} }
twa_graph_edge_data(bdd cond, acc_cond::mark_t acc = 0U) twa_graph_edge_data(bdd cond, acc_cond::mark_t acc = 0U) noexcept
: cond(cond), acc(acc) : cond(cond), acc(acc)
{ {
} }