Skip to content

Commit

Permalink
Utility: simplify IsIterable.
Browse files Browse the repository at this point in the history
After GCC 4.7 support was dropped, turns out we don't need to explicitly
check for std::begin() and thus we also don't need to include <iterator>
for libc++. That's 30k LOC saved on libstdc++ and 8k on libc++. Yay?
  • Loading branch information
mosra committed Feb 10, 2019
1 parent 49f72c6 commit 9b258d7
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/Corrade/Utility/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
* @brief Macros @ref CORRADE_HAS_TYPE(), alias @ref Corrade::Utility::IsIterable
*/

#include <iterator> /* for std::begin() in libc++ */
#include <utility>

#include "Corrade/configure.h"
#include <type_traits>

namespace Corrade { namespace Utility {

Expand Down Expand Up @@ -69,8 +66,6 @@ namespace Implementation {
CORRADE_HAS_TYPE(HasMemberEnd, decltype(std::declval<T>().end()));
CORRADE_HAS_TYPE(HasBegin, decltype(begin(std::declval<T>())));
CORRADE_HAS_TYPE(HasEnd, decltype(end(std::declval<T>())));
CORRADE_HAS_TYPE(HasStdBegin, decltype(std::begin(std::declval<T>())));
CORRADE_HAS_TYPE(HasStdEnd, decltype(std::end(std::declval<T>())));
}

/**
Expand All @@ -86,12 +81,8 @@ equivalent to @ref std::false_type.
constructor doesn't exist */
template<class T> using IsIterable = std::integral_constant<bool,
#ifndef DOXYGEN_GENERATING_OUTPUT
(Implementation::HasMemberBegin<T>::value ||
Implementation::HasBegin<T>::value ||
Implementation::HasStdBegin<T>::value) &&
(Implementation::HasMemberEnd<T>::value ||
Implementation::HasEnd<T>::value ||
Implementation::HasStdEnd<T>::value)
(Implementation::HasMemberBegin<T>::value || Implementation::HasBegin<T>::value) &&
(Implementation::HasMemberEnd<T>::value || Implementation::HasEnd<T>::value)
#else
implementation-specific
#endif
Expand Down

0 comments on commit 9b258d7

Please sign in to comment.