Re: [Boost-bugs] [Boost C++ Libraries] #10829: cardinality() of an interval_set is std::size_t independent of interval type, causing overflow

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10829: cardinality() of an interval_set is std::size_t independent of interval type, causing overflow
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-12-01 10:47:41


#10829: cardinality() of an interval_set is std::size_t independent of interval
type, causing overflow
----------------------------------+---------------------
  Reporter: konstantin.miller@… | Owner: jofaber
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: ICL
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords: ICL
----------------------------------+---------------------

Comment (by bugs@…):

 Out of curiosity, SFINAE-ing the `get_size_type` trait for arithmetic or
 integral types does seem to do what's expected.

 I'm aware of the fact that following code is not up to coding standards
 and Boost guides. I'm just contributing it in case it saves anyone else
 time during analysis:

 Replace

 {{{
 template <class Type>
 struct get_size_type<Type, false, false, false>
 {
     typedef std::size_t type;
 };
 }}}

 with

 {{{
 template <class Type>
 struct get_size_type<Type, std::enable_if<not
 boost::is_arithmetic<Type>::value, mpl::false_>::type::value, false,
 false>
 {
     typedef std::size_t type;
 };

 template <class Type>
 struct get_size_type<Type,
 std::enable_if<boost::is_arithmetic<Type>::value,
 mpl::false_>::type::value, false, false>
 {
     typedef typename std::common_type<Type, std::size_t>::type type;
 };
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10829#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC