summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-internal.h
diff options
context:
space:
mode:
authordrgler <daniel.kruegler@gmail.com>2017-08-09 17:07:22 (GMT)
committerdrgler <daniel.kruegler@gmail.com>2017-08-09 17:08:22 (GMT)
commit71ca4bae1085d7f2adefcbd16b0b7cebb81d540f (patch)
tree1214077ca2650150333566239feaf4c2aa6749c3 /googletest/include/gtest/internal/gtest-internal.h
parent4bab34d2084259cba67f3bfb51217c10d606e175 (diff)
downloadgoogletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.zip
googletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.tar.gz
googletest-71ca4bae1085d7f2adefcbd16b0b7cebb81d540f.tar.bz2
Infinite Loop when calling a mock function that takes boost::filesystem::path as parameter #521: Add is_same type trait and prevent infinite loops for recursive containers
Diffstat (limited to 'googletest/include/gtest/internal/gtest-internal.h')
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 72d83f0..2a6e4da 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -940,6 +940,31 @@ typedef char IsNotContainer;
template <class C>
IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
+template <typename C, bool =
+ sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)
+>
+struct IsRecursiveContainerImpl;
+
+template <typename C>
+struct IsRecursiveContainerImpl<C, false> : public false_type {};
+
+template <typename C>
+struct IsRecursiveContainerImpl<C, true> {
+ typedef
+ typename IteratorTraits<typename C::iterator>::value_type
+ value_type;
+ typedef is_same<value_type, C> type;
+};
+
+// IsRecursiveContainer<Type> is a unary compile-time predicate that
+// evaluates whether C is a recursive container type. A recursive container
+// type is a container type whose value_type is equal to the container type
+// itself. An example for a recursive container type is
+// boost::filesystem::path, whose iterator has a value_type that is equal to
+// boost::filesystem::path.
+template<typename C>
+struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
+
// EnableIf<condition>::type is void when 'Cond' is true, and
// undefined when 'Cond' is false. To use SFINAE to make a function
// overload only apply when a particular expression is true, add