Skip to content

Commit

Permalink
Alter code to avoid GCC duplicated-branches warng
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyelewis committed Nov 12, 2017
1 parent 435a145 commit a725dcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 7 additions & 9 deletions source/seq/seq_seg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace cath {
/// \brief The stop boundary of the segment
seq_arrow stop;

static constexpr bool sanity_check(const seq_arrow &,
const seq_arrow &);
static constexpr seq_arr_seq_arr_pair sanity_check(const seq_arrow &,
const seq_arrow &);

public:
constexpr seq_seg(const seq_arrow &,
Expand All @@ -81,10 +81,10 @@ namespace cath {
/// \brief Sanity check this seq_seg and throw an exception if a problem is detected
///
/// \todo Come GCC >= 5 (with relaxed constexpr), make this code nicer
constexpr bool seq_seg::sanity_check(const seq_arrow &arg_start, ///< The start position
const seq_arrow &arg_stop ///< The stop position
) {
return ( arg_start < arg_stop ) ? true
constexpr seq_arr_seq_arr_pair seq_seg::sanity_check(const seq_arrow &arg_start, ///< The start position
const seq_arrow &arg_stop ///< The stop position
) {
return ( arg_start < arg_stop ) ? std::make_pair( arg_start, arg_stop )
: throw std::invalid_argument( "Cannot create seq_seg with start residue before the stop residue" );
}

Expand All @@ -95,9 +95,7 @@ namespace cath {
const seq_arrow &arg_stop ///< The residue boundary of the segment's stop
) : start{ arg_start },
stop {
sanity_check( arg_start, arg_stop )
? arg_stop
: arg_stop
sanity_check( arg_start, arg_stop ).second
} {
}

Expand Down
3 changes: 3 additions & 0 deletions source/seq/seq_type_aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ namespace cath {
/// \brief Type alias for a vector residx_t
using residx_vec = std::vector<residx_t>;

/// \brief Type alias for a pair of seq_arrows
using seq_arr_seq_arr_pair = std::pair<seq_arrow, seq_arrow>;

/// \brief Type alias for an optional seq_seg
using seq_seg_opt = boost::optional<seq_seg>;

Expand Down

0 comments on commit a725dcd

Please sign in to comment.