From b0439e6d6a7c3cd93589b712b732334803506184 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 8 May 2014 21:52:23 +0000 Subject: StringMap support for move-only values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208359 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/StringMapTest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'unittests') diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp index b6d41bcc8e..42a0388618 100644 --- a/unittests/ADT/StringMapTest.cpp +++ b/unittests/ADT/StringMapTest.cpp @@ -218,4 +218,20 @@ TEST_F(StringMapTest, NonDefaultConstructable) { ASSERT_EQ(iter->second.i, 123); } +struct MoveOnly { + int i; + MoveOnly(int i) : i(i) {} + MoveOnly(MoveOnly&&) = default; + MoveOnly(const MoveOnly&) = delete; + MoveOnly &operator=(MoveOnly&&) = default; + MoveOnly &operator=(const MoveOnly&) = delete; +}; + +TEST_F(StringMapTest, MoveOnlyKey) { + StringMap t; + t.GetOrCreateValue("Test", MoveOnly(42)); + StringRef Key = "Test"; + StringMapEntry::Create(Key.begin(), Key.end(), MoveOnly(42))->Destroy(); +} + } // end anonymous namespace -- cgit v1.2.3