summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/build/tools/addCopyright24
-rw-r--r--src/include/map28
-rw-r--r--src/include/vector8
-rw-r--r--src/usr/testcore/lib/stltest.H24
4 files changed, 75 insertions, 9 deletions
diff --git a/src/build/tools/addCopyright b/src/build/tools/addCopyright
index 5e1c9216c..22453d551 100755
--- a/src/build/tools/addCopyright
+++ b/src/build/tools/addCopyright
@@ -572,16 +572,24 @@ sub filetype
if ( -f $filename )
{
my $type = `grep "\\\$Filetype:.*\\\$" $filename`;
- if ( $type =~ m/\$Filetype:([^\$]*)\$/ )
+ if ($type ne "")
{
- $type = $1;
+ if ( $type =~ m/\$Filetype:([^\$]*)\$/ )
+ {
+ $type = $1;
+ }
+ $type =~ s/^\s*//;
+ $type =~ s/\s*$//;
+ my @knownTypes = qw/ Assembly Automake Autoconf C CVS EmxFile
+ LinkerScript Makefile MofFile Perl PrdRuleFile
+ PrdTestCaseFile Python RPC Shellscript Tcl /;
+ return $type if ( grep(/^$type$/, @knownTypes) );
+ }
+ # Search for files that have the comment /* vim: set filetype=cpp : */
+ elsif (`grep \"set filetype=cpp\" $filename`)
+ {
+ return "C";
}
- $type =~ s/^\s*//;
- $type =~ s/\s*$//;
- my @knownTypes = qw/ Assembly Automake Autoconf C CVS EmxFile
- LinkerScript Makefile MofFile Perl PrdRuleFile
- PrdTestCaseFile Python RPC Shellscript Tcl /;
- return $type if ( grep(/^$type$/, @knownTypes) );
}
{ # Other random files containing non-printable characters.
my $file = `cat $filename`;
diff --git a/src/include/map b/src/include/map
index ddfa17ea7..75e710163 100644
--- a/src/include/map
+++ b/src/include/map
@@ -473,6 +473,34 @@ namespace std
equal_range( const key_type& k) const
{ return submap::equal_range(k); }
};
+
+ /**
+ * @brief Map equality comparison.
+ * @param lhs A map.
+ * @param rhs A map of the same type as lhs.
+ * @return True iff the size and elements of the maps are equal.
+ *
+ * This is an equivalence relation. It is linear in the size of the
+ * maps. Maps are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
+ */
+ template <typename _K, typename _T, typename _C>
+ inline bool operator==(const map<_K,_T,_C>& lhs,
+ const map<_K,_T,_C>& rhs)
+ {
+ return (lhs.size() == rhs.size()) &&
+ (std::equal(lhs.begin(), lhs.end(), rhs.begin()));
+ }
+
+ /**
+ * @brief Map inequality comparison. See operator==
+ */
+ template <typename _K, typename _T, typename _C>
+ inline bool operator!=(const map<_K,_T,_C>& lhs,
+ const map<_K,_T,_C>& rhs)
+ {
+ return !(lhs == rhs);
+ }
};
#endif
diff --git a/src/include/vector b/src/include/vector
index ac502a047..198d086cb 100644
--- a/src/include/vector
+++ b/src/include/vector
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2016 */
+/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -730,6 +730,12 @@ namespace std
return true;
}
+ template <class T, class U>
+ bool operator!=(const vector<T>& l, const vector<U>& r)
+ {
+ return !(l == r);
+ }
+
}; // end namespace std
// ------------------------------------------------------------------------------------------------
diff --git a/src/usr/testcore/lib/stltest.H b/src/usr/testcore/lib/stltest.H
index c16354ff3..31cc3cbe9 100644
--- a/src/usr/testcore/lib/stltest.H
+++ b/src/usr/testcore/lib/stltest.H
@@ -233,6 +233,30 @@ class STLTest : public CxxTest::TestSuite
}
+ // Test map comparison with non-integral key,value pairs
+ std::map<std::array<int,3>, std::vector<int> > m1 = {
+ { {1,2,3}, {100, 101, 102} },
+ { {4,5,6}, {103, 104, 105} },
+ { {7,8,9}, {106, 107, 108} },
+ { {10,11,12}, {109, 110, 111} },
+ };
+ std::map<std::array<int,3>, std::vector<int> > m2 = {
+ { {10,11,12}, {109, 110, 111} },
+ { {7,8,9}, {106, 107, 108} },
+ { {4,5,6}, {103, 104, 105} },
+ { {1,2,3}, {100, 101, 102} },
+ };
+
+ if (m1 != m2)
+ {
+ TS_FAIL("std::map operator!= is true on equal maps");
+ }
+ m2.at({1,2,3}).at(0) = 99;
+ if (m1 == m2)
+ {
+ TS_FAIL("std::map operator== is true on unequal maps");
+ }
+
}
OpenPOWER on IntegriCloud