Skip to content

Commit

Permalink
Merge pull request #14 from boostorg/develop
Browse files Browse the repository at this point in the history
Merge from develop
  • Loading branch information
ericniebler authored Nov 2, 2020
2 parents 88c8eae + 6ee16b1 commit ba7b0ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions doc/foreach.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,19 @@ loop variable is a template. Consider trying to iterate over a `std::map`:
std::map<int,int> m;

// ERROR! Too many arguments to BOOST_FOREACH macro.
BOOST_FOREACH(std::pair<int,int> p, m) // ...
BOOST_FOREACH(std::pair<const int,int> p, m) // ...

One way to fix this is with a typedef.

std::map<int,int> m;
typedef std::pair<int,int> pair_t;
typedef std::pair<const int,int> pair_t;

BOOST_FOREACH(pair_t p, m) // ...

Another way to fix it is to predeclare the loop variable:

std::map<int,int> m;
std::pair<int,int> p;
std::pair<const int,int> p;

BOOST_FOREACH(p, m) // ...

Expand Down
6 changes: 3 additions & 3 deletions include/boost/foreach.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// Some compilers allow temporaries to be bound to non-const references.
// These compilers make it impossible to for BOOST_FOREACH to detect
// temporaries and avoid reevaluation of the collection expression.
# if BOOST_WORKAROUND(__BORLANDC__, < 0x593) \
# if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x593) \
|| (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \
|| BOOST_WORKAROUND(__DECCXX_VER, <= 60590042)
Expand All @@ -65,7 +65,7 @@
|| BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, >= 0x5100) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590))
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x590))
# define BOOST_FOREACH_NO_CONST_RVALUE_DETECTION
# else
# define BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
Expand Down Expand Up @@ -436,7 +436,7 @@ inline T *&to_ptr(T const &)
}

// Borland needs a little extra help with arrays
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
template<typename T,std::size_t N>
inline T (*&to_ptr(T (&)[N]))[N]
{
Expand Down

0 comments on commit ba7b0ba

Please sign in to comment.