Avoids iterator_traits, as it's not available in libCStd when compiled with Sun C++.
This commit is contained in:
parent
e9adbcbb56
commit
fc99b1ad51
@ -306,11 +306,10 @@ internal::ParamGenerator<T> Range(T start, T end) {
|
||||
//
|
||||
template <typename ForwardIterator>
|
||||
internal::ParamGenerator<
|
||||
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||
ForwardIterator begin,
|
||||
ForwardIterator end) {
|
||||
typedef typename ::std::iterator_traits<ForwardIterator>::value_type
|
||||
ParamType;
|
||||
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
|
||||
ValuesIn(ForwardIterator begin, ForwardIterator end) {
|
||||
typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
|
||||
::value_type ParamType;
|
||||
return internal::ParamGenerator<ParamType>(
|
||||
new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
|
||||
}
|
||||
|
@ -305,11 +305,10 @@ internal::ParamGenerator<T> Range(T start, T end) {
|
||||
//
|
||||
template <typename ForwardIterator>
|
||||
internal::ParamGenerator<
|
||||
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||
ForwardIterator begin,
|
||||
ForwardIterator end) {
|
||||
typedef typename ::std::iterator_traits<ForwardIterator>::value_type
|
||||
ParamType;
|
||||
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
|
||||
ValuesIn(ForwardIterator begin, ForwardIterator end) {
|
||||
typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
|
||||
::value_type ParamType;
|
||||
return internal::ParamGenerator<ParamType>(
|
||||
new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
|
||||
// This file was GENERATED by command:
|
||||
// pump.py gtest-param-util-generated.h.pump
|
||||
// DO NOT EDIT BY HAND!!!
|
||||
|
||||
// Copyright 2008 Google Inc.
|
||||
// All Rights Reserved.
|
||||
@ -58,8 +60,8 @@ namespace testing {
|
||||
// include/gtest/gtest-param-test.h.
|
||||
template <typename ForwardIterator>
|
||||
internal::ParamGenerator<
|
||||
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||
ForwardIterator begin, ForwardIterator end);
|
||||
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
|
||||
ValuesIn(ForwardIterator begin, ForwardIterator end);
|
||||
|
||||
template <typename T, size_t N>
|
||||
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
|
||||
|
@ -59,8 +59,8 @@ namespace testing {
|
||||
// include/gtest/gtest-param-test.h.
|
||||
template <typename ForwardIterator>
|
||||
internal::ParamGenerator<
|
||||
typename ::std::iterator_traits<ForwardIterator>::value_type> ValuesIn(
|
||||
ForwardIterator begin, ForwardIterator end);
|
||||
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
|
||||
ValuesIn(ForwardIterator begin, ForwardIterator end);
|
||||
|
||||
template <typename T, size_t N>
|
||||
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
|
||||
|
@ -140,6 +140,8 @@
|
||||
//
|
||||
// Template meta programming:
|
||||
// is_pointer - as in TR1; needed on Symbian and IBM XL C/C++ only.
|
||||
// IteratorTraits - partial implementation of std::iterator_traits, which
|
||||
// is not available in libCstd when compiled with Sun C++.
|
||||
//
|
||||
// Smart pointers:
|
||||
// scoped_ptr - as in TR2.
|
||||
@ -1466,6 +1468,21 @@ struct is_pointer : public false_type {};
|
||||
template <typename T>
|
||||
struct is_pointer<T*> : public true_type {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct IteratorTraits {
|
||||
typedef typename Iterator::value_type value_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IteratorTraits<T*> {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IteratorTraits<const T*> {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
# define GTEST_PATH_SEP_ "\\"
|
||||
# define GTEST_HAS_ALT_PATH_SEP_ 1
|
||||
|
@ -39,7 +39,9 @@
|
||||
# include <time.h>
|
||||
#endif // GTEST_OS_MAC
|
||||
|
||||
#include <list>
|
||||
#include <utility> // For std::pair and std::make_pair.
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gtest/gtest-spi.h"
|
||||
@ -172,6 +174,24 @@ TEST(ImplicitCastTest, CanUseImplicitConstructor) {
|
||||
EXPECT_TRUE(converted);
|
||||
}
|
||||
|
||||
TEST(IteratorTraitsTest, WorksForSTLContainerIterators) {
|
||||
StaticAssertTypeEq<int,
|
||||
IteratorTraits< ::std::vector<int>::const_iterator>::value_type>();
|
||||
StaticAssertTypeEq<bool,
|
||||
IteratorTraits< ::std::list<bool>::iterator>::value_type>();
|
||||
}
|
||||
|
||||
TEST(IteratorTraitsTest, WorksForPointerToNonConst) {
|
||||
StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>();
|
||||
StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>();
|
||||
}
|
||||
|
||||
TEST(IteratorTraitsTest, WorksForPointerToConst) {
|
||||
StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>();
|
||||
StaticAssertTypeEq<const void*,
|
||||
IteratorTraits<const void* const*>::value_type>();
|
||||
}
|
||||
|
||||
// Tests that the element_type typedef is available in scoped_ptr and refers
|
||||
// to the parameter type.
|
||||
TEST(ScopedPtrTest, DefinesElementType) {
|
||||
|
Loading…
Reference in New Issue
Block a user