Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gogagum committed Jan 19, 2025
1 parent 367f73c commit 141001a
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 59 deletions.
2 changes: 1 addition & 1 deletion include/boost/generator_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct generator_iterator_generator

template <class Generator>
inline generator_iterator<Generator>
make_generator_iterator(Generator & gen)
make_generator_iterator(Generator& gen)
{
typedef generator_iterator<Generator> result_t;
return result_t(&gen);
Expand Down
6 changes: 0 additions & 6 deletions include/boost/iterator/detail/config_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@
# define BOOST_NO_IS_CONVERTIBLE // "is_convertible doesn't work for simple types"
#endif

#if BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4) && !defined(__EDG_VERSION__) \
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile:

# if 0 // test code
#include <type_traits>
template <class T>
Expand All @@ -107,8 +103,6 @@
bool x = std::is_convertible<foo<int const*>, foo<int*> >::value;
# endif

#endif

# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))

// GCC-2.95 (obsolete) eagerly instantiates templated constructors and conversion
Expand Down
1 change: 0 additions & 1 deletion include/boost/iterator/detail/config_undef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//

#undef BOOST_NO_IS_CONVERTIBLE
#undef BOOST_NO_IS_CONVERTIBLE_TEMPLATE
#undef BOOST_NO_LVALUE_RETURN_DETECTION
#undef BOOST_NO_ONE_WAY_ITERATOR_INTEROP

Expand Down
32 changes: 16 additions & 16 deletions include/boost/iterator/function_input_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ namespace iterators {
iterators::function_input_iterator<Function, Input>,
typename result_of_nullary_lvalue_call<Function>::type,
single_pass_traversal_tag,
typename result_of_nullary_lvalue_call<Function>::type const &
typename result_of_nullary_lvalue_call<Function>::type const&
>
{
public:
function_object_input_iterator() {}
function_object_input_iterator(Function & f_, Input state_ = Input())
: f(addressof(f_)), state(state_) {}
function_object_input_iterator(Function& f_, Input state_ = Input())
: f(boost::addressof(f_)), state(state_) {}

void increment() {
if (value)
Expand All @@ -66,14 +66,14 @@ namespace iterators {
++state;
}

typename result_of_nullary_lvalue_call<Function>::type const &
typename result_of_nullary_lvalue_call<Function>::type const&
dereference() const {
if (!value)
value = (*f)();
return value.get();
}

bool equal(function_object_input_iterator const & other) const {
bool equal(function_object_input_iterator const& other) const {
return f == other.f && state == other.state;
}

Expand All @@ -89,12 +89,12 @@ namespace iterators {
iterators::function_input_iterator<Function, Input>,
typename function_types::result_type<Function>::type,
single_pass_traversal_tag,
typename function_types::result_type<Function>::type const &
typename function_types::result_type<Function>::type const&
>
{
public:
function_pointer_input_iterator() {}
function_pointer_input_iterator(Function &f_, Input state_ = Input())
function_pointer_input_iterator(Function& f_, Input state_ = Input())
: f(f_), state(state_) {}

void increment() {
Expand All @@ -105,14 +105,14 @@ namespace iterators {
++state;
}

typename function_types::result_type<Function>::type const &
typename function_types::result_type<Function>::type const&
dereference() const {
if (!value)
value = (*f)();
return value.get();
}

bool equal(function_pointer_input_iterator const & other) const {
bool equal(function_pointer_input_iterator const& other) const {
return f == other.f && state == other.state;
}

Expand All @@ -138,30 +138,30 @@ namespace iterators {
impl::function_object_input_iterator<Function,Input>
>::type base_type;
public:
function_input_iterator(Function & f, Input i)
function_input_iterator(Function& f, Input i)
: base_type(f, i) {}
};

template <class Function, class Input>
inline function_input_iterator<Function, Input>
make_function_input_iterator(Function & f, Input state) {
make_function_input_iterator(Function& f, Input state) {
typedef function_input_iterator<Function, Input> result_t;
return result_t(f, state);
}

template <class Function, class Input>
inline function_input_iterator<Function*, Input>
make_function_input_iterator(Function * f, Input state) {
make_function_input_iterator(Function* f, Input state) {
typedef function_input_iterator<Function*, Input> result_t;
return result_t(f, state);
}

struct infinite
{
infinite & operator++() { return *this; }
infinite & operator++(int) { return *this; }
bool operator==(infinite &) const { return false; };
bool operator==(infinite const &) const { return false; };
infinite& operator++() { return *this; }
infinite& operator++(int) { return *this; }
bool operator==(infinite&) const { return false; };
bool operator==(infinite const&) const { return false; };
};

} // namespace iterators
Expand Down
2 changes: 1 addition & 1 deletion include/boost/iterator/iterator_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace iterators {
public:
iterator_adaptor() {}

explicit iterator_adaptor(Base const &iter)
explicit iterator_adaptor(Base const& iter)
: m_iterator(iter)
{
}
Expand Down
10 changes: 5 additions & 5 deletions include/boost/iterator/iterator_facade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ namespace iterators {
{
struct proxy
{
explicit proxy(Reference const & x) : m_ref(x) {}
explicit proxy(Reference const& x) : m_ref(x) {}
Reference* operator->() { return boost::addressof(m_ref); }
// This function is needed for MWCW and BCC, which won't call
// operator-> again automatically per 13.3.1.2 para 8
operator Reference*() { return boost::addressof(m_ref); }
Reference m_ref;
};
typedef proxy result_type;
static result_type apply(Reference const & x)
static result_type apply(Reference const& x)
{
return result_type(x);
}
Expand Down Expand Up @@ -459,7 +459,7 @@ namespace iterators {
template <class Iterator>
typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, std::false_type)
{
return *iter;
return *iter;
}

struct choose_difference_type
Expand Down Expand Up @@ -769,11 +769,11 @@ namespace iterators {
typename boost::iterators::detail::operator_brackets_result<Derived, Value, reference>::type
operator[](difference_type n) const
{
const auto use_proxy = boost::iterators::detail::use_operator_brackets_proxy<Value, Reference>::value;
using use_proxy = boost::iterators::detail::use_operator_brackets_proxy<Value, Reference>;

return boost::iterators::detail::make_operator_brackets_result<Derived>(
this->derived() + n
, std::integral_constant<bool, use_proxy>{}
, std::integral_constant<bool, use_proxy::value>{}
);
}

Expand Down
44 changes: 28 additions & 16 deletions include/boost/iterator/new_iterator_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ namespace boost {
// Do separate tests for *i++ so we can treat, e.g., smart pointers,
// as readable and/or writable iterators.
template <class Iterator, class T>
void readable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
void readable_iterator_traversal_test(Iterator i1, T v, std::true_type)
{
T v2(*i1++);
BOOST_TEST(v == v2);
}

template <class Iterator, class T>
void readable_iterator_traversal_test(const Iterator i1, T v, std::false_type) {}
void readable_iterator_traversal_test(const Iterator i1, T v, std::false_type)
{}

template <class Iterator, class T>
void writable_iterator_traversal_test(Iterator i1, T v, std::true_type) {
void writable_iterator_traversal_test(Iterator i1, T v, std::true_type)
{
++i1; // we just wrote into that position
*i1++ = v;
Iterator x(i1++);
Expand All @@ -66,7 +69,8 @@ void writable_iterator_traversal_test(const Iterator i1, T v, std::false_type) {

// Preconditions: *i == v
template <class Iterator, class T>
void readable_iterator_test(const Iterator i1, T v) {
void readable_iterator_test(const Iterator i1, T v)
{
Iterator i2(i1); // Copy Constructible
typedef typename std::iterator_traits<Iterator>::reference ref_t;
ref_t r1 = *i1;
Expand Down Expand Up @@ -104,7 +108,9 @@ void writable_iterator_test(Iterator i, T v, T v2) {
#endif
}

template <class Iterator> void swappable_iterator_test(Iterator i, Iterator j) {
template <class Iterator>
void swappable_iterator_test(Iterator i, Iterator j)
{
Iterator i2(i), j2(j);
typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
iter_swap(i2, j2);
Expand All @@ -117,10 +123,10 @@ void constant_lvalue_iterator_test(Iterator i, T v1) {
Iterator i2(i);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
static_assert(std::is_same<const value_type &, reference>::value,
static_assert(std::is_same<const value_type&, reference>::value,
"reference type must be the same as const value_type& for "
"constant lvalue iterator.");
const T &v2 = *i2;
const T& v2 = *i2;
BOOST_TEST(v1 == v2);
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value
Expand All @@ -134,17 +140,17 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) {
Iterator i2(i);
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
static_assert(std::is_same<value_type &, reference>::value,
static_assert(std::is_same<value_type&, reference>::value,
"reference type must be the same as value_type& for "
"non-constant lvalue iterator.");
T &v3 = *i2;
T& v3 = *i2;
BOOST_TEST(v1 == v3);

// A non-const lvalue iterator is not necessarily writable, but we
// are assuming the value_type is assignable here
*i = v2;

T &v4 = *i2;
T& v4 = *i2;
BOOST_TEST(v2 == v4);
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
static_assert(is_lvalue_iterator<Iterator>::value,
Expand All @@ -155,7 +161,8 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) {
}

template <class Iterator, class T>
void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2)
{
Iterator i2;
Iterator i3(i);
i2 = i;
Expand All @@ -176,7 +183,8 @@ void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
}

template <class Iterator, class T>
void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2)
{
forward_readable_iterator_test(i, j, val1, val2);
Iterator i2 = i;
++i2;
Expand All @@ -186,7 +194,8 @@ void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2) {
// bidirectional
// Preconditions: *i == v1, *++i == v2
template <class Iterator, class T>
void bidirectional_readable_iterator_test(Iterator i, T v1, T v2) {
void bidirectional_readable_iterator_test(Iterator i, T v1, T v2)
{
Iterator j(i);
++j;
forward_readable_iterator_test(i, j, v1, v2);
Expand Down Expand Up @@ -215,12 +224,14 @@ void bidirectional_readable_iterator_test(Iterator i, T v1, T v2) {
// random access
// Preconditions: [i,i+N) is a valid range
template <class Iterator, class TrueVals>
void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) {
void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
{
bidirectional_readable_iterator_test(i, vals[0], vals[1]);
const Iterator j = i;
int c;

for (c = 0; c < N - 1; ++c) {
for (c = 0; c < N - 1; ++c)
{
BOOST_TEST(i == j + c);
BOOST_TEST(*i == vals[c]);
typename std::iterator_traits<Iterator>::value_type x = j[c];
Expand All @@ -235,7 +246,8 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) {
}

Iterator k = j + N - 1;
for (c = 0; c < N - 1; ++c) {
for (c = 0; c < N - 1; ++c)
{
BOOST_TEST(i == k - c);
BOOST_TEST(*i == vals[N - 1 - c]);
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
Expand Down
24 changes: 12 additions & 12 deletions test/iterator_facade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,19 @@ template <class I, class A>
struct abstract_iterator
: boost::iterator_facade<
abstract_iterator<I, A>
, A &
, A&
// In order to be value type as a reference, traversal category has
// to satisfy least forward traversal.
, boost::forward_traversal_tag
, A &
, A&
>
{
abstract_iterator(I iter) : iter(iter) {}

void increment()
{ ++iter; }

A & dereference() const
A& dereference() const
{ return *iter; }

bool equal(abstract_iterator const& y) const
Expand All @@ -172,30 +172,30 @@ struct abstract_iterator

struct base
{
virtual void assign(const base &) = 0;
virtual bool equal(const base &) const = 0;
virtual void assign(const base&) = 0;
virtual bool equal(const base&) const = 0;
};

struct derived : base
{
derived(int state) : state(state) { }
derived(const derived &d) : state(d.state) { }
derived(const base &b) { derived::assign(b); }
derived(const derived& d) : state(d.state) { }
derived(const base& b) { derived::assign(b); }

virtual void assign(const base &b)
virtual void assign(const base& b)
{
state = dynamic_cast<const derived &>(b).state;
state = dynamic_cast<const derived& >(b).state;
}

virtual bool equal(const base &b) const
virtual bool equal(const base& b) const
{
return state == dynamic_cast<const derived &>(b).state;
return state == dynamic_cast<const derived&>(b).state;
}

int state;
};

inline bool operator==(const base &lhs, const base &rhs)
inline bool operator==(const base& lhs, const base& rhs)
{
return lhs.equal(rhs);
}
Expand Down
2 changes: 1 addition & 1 deletion test/static_assert_same.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <type_traits>

#define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same<T1, T2>::value, "T1 ans T2 are expected to be the same types.")
#define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same<T1, T2>::value, "T1 and T2 are expected to be the same types.")

template <class T1, class T2>
struct static_assert_same
Expand Down

0 comments on commit 141001a

Please sign in to comment.