Skip to content

Commit

Permalink
Moved most components of the library to iterators:: namespace.
Browse files Browse the repository at this point in the history
This change excludes boost:: and boost::detail:: namespaces from ADL for unqualified function calls (e.g. algorithms). This reduces the possibility of name clashes with other libraries and user's code. One of the effects should be fixing test failures on gcc 4.2 and 4.4 due to clashed with Boost.TypeTraits.

Also some of the functions marked with inline keyword.
  • Loading branch information
Lastique committed Jul 2, 2014
1 parent e000b67 commit dc96d37
Show file tree
Hide file tree
Showing 28 changed files with 595 additions and 441 deletions.
12 changes: 9 additions & 3 deletions include/boost/function_output_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <iterator>

namespace boost {
namespace iterators {

template <class UnaryFunction>
class function_output_iterator {
Expand All @@ -33,13 +34,13 @@ namespace boost {
struct output_proxy {
output_proxy(UnaryFunction& f) : m_f(f) { }
template <class T> output_proxy& operator=(const T& value) {
m_f(value);
return *this;
m_f(value);
return *this;
}
UnaryFunction& m_f;
};
output_proxy operator*() { return output_proxy(m_f); }
self& operator++() { return *this; }
self& operator++() { return *this; }
self& operator++(int) { return *this; }
private:
UnaryFunction m_f;
Expand All @@ -51,6 +52,11 @@ namespace boost {
return function_output_iterator<UnaryFunction>(f);
}

} // namespace iterators

using iterators::function_output_iterator;
using iterators::make_function_output_iterator;

} // namespace boost

#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
11 changes: 8 additions & 3 deletions include/boost/generator_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <boost/ref.hpp>

namespace boost {
namespace iterators {

template<class Generator>
class generator_iterator
Expand All @@ -33,7 +34,7 @@ class generator_iterator
, single_pass_traversal_tag
, typename Generator::result_type const&
> super_t;

public:
generator_iterator() {}
generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {}
Expand Down Expand Up @@ -73,8 +74,12 @@ make_generator_iterator(Generator & gen)
return result_t(&gen);
}

} // namespace boost
} // namespace iterators

using iterators::generator_iterator;
using iterators::generator_iterator_generator;
using iterators::make_generator_iterator;

#endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
} // namespace boost

#endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
4 changes: 2 additions & 2 deletions include/boost/indirect_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# include <boost/mpl/eval_if.hpp>
# include <boost/pointee.hpp>

namespace boost {
namespace boost {

namespace detail
{
Expand All @@ -37,7 +37,7 @@ struct indirect_reference
>
{
};

} // namespace boost

#endif // INDIRECT_REFERENCE_DWA200415_HPP
41 changes: 23 additions & 18 deletions include/boost/iterator/counting_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# include <boost/mpl/eval_if.hpp>

namespace boost {
namespace iterators {

template <
class Incrementable
Expand All @@ -30,13 +31,13 @@ namespace detail
{
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);

# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS

BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<T>::is_specialized);

# else

# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
BOOST_STATIC_CONSTANT(
bool, value = (
Expand All @@ -46,20 +47,20 @@ namespace detail
# else
BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic<T>::value);
# endif

# endif
};

template <class T>
struct is_numeric
: mpl::bool_<(::boost::detail::is_numeric_impl<T>::value)>
: mpl::bool_<(::boost::iterators::detail::is_numeric_impl<T>::value)>
{};

# if defined(BOOST_HAS_LONG_LONG)
template <>
struct is_numeric< ::boost::long_long_type>
: mpl::true_ {};

template <>
struct is_numeric< ::boost::ulong_long_type>
: mpl::true_ {};
Expand All @@ -69,15 +70,15 @@ namespace detail
template <>
struct is_numeric<wchar_t>
: mpl::true_ {};

template <class T>
struct numeric_difference
{
typedef typename boost::detail::numeric_traits<T>::difference_type type;
};

BOOST_STATIC_ASSERT(is_numeric<int>::value);

template <class Incrementable, class CategoryOrTraversal, class Difference>
struct counting_iterator_base
{
Expand All @@ -89,7 +90,7 @@ namespace detail
, iterator_traversal<Incrementable>
>
>::type traversal;

typedef typename detail::ia_dflt_help<
Difference
, mpl::eval_if<
Expand All @@ -98,15 +99,15 @@ namespace detail
, iterator_difference<Incrementable>
>
>::type difference;

typedef iterator_adaptor<
counting_iterator<Incrementable, CategoryOrTraversal, Difference> // self
, Incrementable // Base
, Incrementable // Value
# ifndef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
const // MSVC won't strip this. Instead we enable Thomas'
// criterion (see boost/iterator/detail/facade_iterator_category.hpp)
# endif
# endif
, traversal
, Incrementable const& // reference
, difference
Expand Down Expand Up @@ -136,7 +137,7 @@ namespace detail
{
static Difference distance(Incrementable1 x, Incrementable2 y)
{
return numeric_distance(x, y);
return boost::detail::numeric_distance(x, y);
}
};
}
Expand All @@ -154,14 +155,14 @@ class counting_iterator
typedef typename detail::counting_iterator_base<
Incrementable, CategoryOrTraversal, Difference
>::type super_t;

friend class iterator_core_access;

public:
typedef typename super_t::difference_type difference_type;

counting_iterator() { }

counting_iterator(counting_iterator const& rhs) : super_t(rhs.base()) {}

counting_iterator(Incrementable x)
Expand All @@ -177,10 +178,10 @@ class counting_iterator
)
: super_t(t.base())
{}
# endif
# endif

private:

typename super_t::reference dereference() const
{
return this->base_reference();
Expand Down Expand Up @@ -209,7 +210,11 @@ make_counting_iterator(Incrementable x)
return result_t(x);
}

} // namespace iterators

using iterators::counting_iterator;
using iterators::make_counting_iterator;

} // namespace boost::iterator
} // namespace boost

#endif // COUNTING_ITERATOR_DWA200348_HPP
6 changes: 4 additions & 2 deletions include/boost/iterator/detail/any_conversion_eater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#ifndef ANY_CONVERSION_EATER_DWA20031117_HPP
# define ANY_CONVERSION_EATER_DWA20031117_HPP

namespace boost { namespace detail {
namespace boost {
namespace iterators {
namespace detail {

// This type can be used in traits to "eat" up the one user-defined
// implicit conversion allowed.
Expand All @@ -14,6 +16,6 @@ struct any_conversion_eater
any_conversion_eater(T const&);
};

}} // namespace boost::detail
}}} // namespace boost::iterators::detail

#endif // ANY_CONVERSION_EATER_DWA20031117_HPP
21 changes: 12 additions & 9 deletions include/boost/iterator/detail/facade_iterator_category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
// iterator_category deduction for iterator_facade
//

namespace boost {
namespace iterators {

// forward declaration
namespace boost { struct use_default; }
struct use_default;

namespace boost { namespace detail {
namespace detail {

struct input_output_iterator_tag
: std::input_iterator_tag
Expand Down Expand Up @@ -63,9 +66,9 @@ struct iterator_writability_disabled
, boost::detail::indirect_traits::is_reference_to_const<Reference>
, is_const<ValueParam>
>
# else
# else
: is_const<ValueParam>
# endif
# endif
{};


Expand Down Expand Up @@ -96,7 +99,7 @@ struct iterator_facade_default_category
, typename mpl::eval_if<
mpl::and_<
is_convertible<Traversal, single_pass_traversal_tag>

// check for readability
, is_convertible<Reference, ValueParam>
>
Expand Down Expand Up @@ -146,7 +149,7 @@ struct iterator_category_with_traversal
BOOST_MPL_ASSERT_NOT((is_iterator_traversal<Category>));
# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
BOOST_MPL_ASSERT((is_iterator_traversal<Traversal>));
# endif
# endif
};

// Computes an iterator_category tag whose traversal is Traversal and
Expand All @@ -155,11 +158,11 @@ template <class Traversal, class ValueParam, class Reference>
struct facade_iterator_category_impl
{
BOOST_MPL_ASSERT_NOT((is_iterator_category<Traversal>));

typedef typename iterator_facade_default_category<
Traversal,ValueParam,Reference
>::type category;

typedef typename mpl::if_<
is_same<
Traversal
Expand All @@ -183,7 +186,7 @@ struct facade_iterator_category
{
};

}} // namespace boost::detail
}}} // namespace boost::iterators::detail

# include <boost/iterator/detail/config_undef.hpp>

Expand Down
18 changes: 10 additions & 8 deletions include/boost/iterator/detail/minimum_category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@

# include <boost/mpl/aux_/lambda_support.hpp>

namespace boost { namespace detail {
namespace boost {
namespace iterators {
namespace detail {
//
// Returns the minimum category type or error_type
// if T1 and T2 are unrelated.
//
// For compilers not supporting is_convertible this only
// works with the new boost return and traversal category
// types. The exact boost _types_ are required. No derived types
// will work.
// will work.
//
//
template <bool GreaterEqual, bool LessEqual>
struct minimum_category_impl;

template <class T1, class T2>
struct error_not_related_by_convertibility;

template <>
struct minimum_category_impl<true,false>
{
Expand Down Expand Up @@ -66,17 +68,17 @@ struct minimum_category_impl<false,false>
template <class T1 = mpl::_1, class T2 = mpl::_2>
struct minimum_category
{
typedef minimum_category_impl<
typedef minimum_category_impl<
::boost::is_convertible<T1,T2>::value
, ::boost::is_convertible<T2,T1>::value
> outer;

typedef typename outer::template apply<T1,T2> inner;
typedef typename inner::type type;

BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2))
};

template <>
struct minimum_category<mpl::_1,mpl::_2>
{
Expand All @@ -86,7 +88,7 @@ struct minimum_category<mpl::_1,mpl::_2>

BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2))
};
}} // namespace boost::detail

}}} // namespace boost::iterators::detail

#endif // MINIMUM_CATEGORY_DWA20031119_HPP
Loading

0 comments on commit dc96d37

Please sign in to comment.