Ticket #5650: filesystem.patch
File filesystem.patch, 2.8 KB (added by , 11 years ago) |
---|
-
boost/filesystem/v3/path.hpp
29 29 #include <boost/shared_ptr.hpp> 30 30 #include <boost/io/detail/quoted_manip.hpp> 31 31 #include <boost/static_assert.hpp> 32 #include <boost/functional/hash_fwd.hpp> 32 33 #include <string> 33 34 #include <iterator> 34 35 #include <cstring> … … 565 566 inline bool operator==(const path& lhs, const path::string_type& rhs) { return lhs == rhs.c_str(); } 566 567 inline bool operator==(const path::string_type& lhs, const path& rhs) { return rhs == lhs.c_str(); } 567 568 inline bool operator==(const path::value_type* lhs, const path& rhs) { return rhs == lhs; } 569 570 inline std::size_t hash_value(const path& x) 571 { 572 std::size_t seed = 0; 573 for(const path::value_type* it = x.c_str(); *it; ++it) 574 hash_combine(seed, *it == '/' ? L'\\' : *it); 575 return seed; 576 } 568 577 # else // BOOST_POSIX_API 569 578 inline bool operator==(const path& lhs, const path& rhs) { return lhs.native() == rhs.native(); } 570 579 inline bool operator==(const path& lhs, const path::string_type& rhs) { return lhs.native() == rhs; } 571 580 inline bool operator==(const path& lhs, const path::value_type* rhs) { return lhs.native() == rhs; } 572 581 inline bool operator==(const path::string_type& lhs, const path& rhs) { return lhs == rhs.native(); } 573 582 inline bool operator==(const path::value_type* lhs, const path& rhs) { return lhs == rhs.native(); } 583 584 inline std::size_t hash_value(const path& x) 585 { 586 return hash_range(x.native().begin(), x.native().end()); 587 } 574 588 # endif 575 589 576 590 inline bool operator!=(const path& lhs, const path& rhs) { return !(lhs == rhs); } -
libs/filesystem/v3/test/path_unit_test.cpp
43 43 #include <boost/detail/lightweight_test.hpp> 44 44 #include <boost/detail/lightweight_main.hpp> 45 45 #include <boost/smart_ptr.hpp> // used constructor tests 46 #include <boost/functional/hash.hpp> 46 47 47 48 #include <iostream> 48 49 #include <iomanip> … … 399 400 { 400 401 std::cout << "testing relationals..." << std::endl; 401 402 403 boost::hash<path> hash; 404 402 405 # ifdef BOOST_WINDOWS_API 403 406 // this is a critical use case to meet user expectations 404 407 CHECK(path("c:\\abc") == path("c:/abc")); 408 CHECK(hash(path("c:\\abc")) == hash(path("c:/abc"))); 405 409 # endif 406 410 407 411 const path p("bar"); … … 431 435 CHECK(L"baz" == p2); 432 436 CHECK(wstring(L"baz") == p2); 433 437 438 CHECK(hash(p) == hash(p)); 439 CHECK(hash(p) != hash(p2)); // Not strictly required, but desirable 440 434 441 CHECK(!(p != p)); 435 442 CHECK(p != p2); 436 443 CHECK(p2 != p);