OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 set.add(CountCopy(&counter)); | 688 set.add(CountCopy(&counter)); |
689 | 689 |
690 Set other(set); | 690 Set other(set); |
691 counter = 0; | 691 counter = 0; |
692 set = std::move(other); | 692 set = std::move(other); |
693 EXPECT_EQ(0, counter); | 693 EXPECT_EQ(0, counter); |
694 } | 694 } |
695 | 695 |
696 class MoveOnly { | 696 class MoveOnly { |
697 public: | 697 public: |
698 // kEmpty and kDeleted have special meanings when MoveOnly is used as the key
of a hash table. | 698 // kEmpty and kDeleted have special meanings when MoveOnly is used as the key |
| 699 // of a hash table. |
699 enum { kEmpty = 0, kDeleted = -1, kMovedOut = -2 }; | 700 enum { kEmpty = 0, kDeleted = -1, kMovedOut = -2 }; |
700 | 701 |
701 explicit MoveOnly(int value = kEmpty, int id = 0) | 702 explicit MoveOnly(int value = kEmpty, int id = 0) |
702 : m_value(value), m_id(id) {} | 703 : m_value(value), m_id(id) {} |
703 MoveOnly(MoveOnly&& other) : m_value(other.m_value), m_id(other.m_id) { | 704 MoveOnly(MoveOnly&& other) : m_value(other.m_value), m_id(other.m_id) { |
704 other.m_value = kMovedOut; | 705 other.m_value = kMovedOut; |
705 other.m_id = 0; | 706 other.m_id = 0; |
706 } | 707 } |
707 MoveOnly& operator=(MoveOnly&& other) { | 708 MoveOnly& operator=(MoveOnly&& other) { |
708 m_value = other.m_value; | 709 m_value = other.m_value; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 813 |
813 // ... but they don't have any pass-out (like take()) methods. | 814 // ... but they don't have any pass-out (like take()) methods. |
814 | 815 |
815 set.remove(MoveOnly(3)); | 816 set.remove(MoveOnly(3)); |
816 set.clear(); | 817 set.clear(); |
817 } | 818 } |
818 | 819 |
819 } // anonymous namespace | 820 } // anonymous namespace |
820 | 821 |
821 } // namespace WTF | 822 } // namespace WTF |
OLD | NEW |