diff --git a/include/fmt/format.h b/include/fmt/format.h index 6013c537..d827306a 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -145,13 +145,6 @@ FMT_END_NAMESPACE # define FMT_USE_TRAILING_RETURN 0 #endif -#if FMT_HAS_GXX_CXX11 || FMT_HAS_FEATURE(cxx_rvalue_references) || \ - FMT_MSC_VER >= 1600 -# define FMT_USE_RVALUE_REFERENCES 1 -#else -# define FMT_USE_RVALUE_REFERENCES 0 -#endif - #ifndef FMT_USE_GRISU # define FMT_USE_GRISU 0 #endif diff --git a/include/fmt/posix.h b/include/fmt/posix.h index cadb6d2a..2fb01260 100644 --- a/include/fmt/posix.h +++ b/include/fmt/posix.h @@ -139,50 +139,6 @@ class buffered_file { // Destroys the object closing the file it represents if any. FMT_API ~buffered_file() FMT_DTOR_NOEXCEPT; -#if !FMT_USE_RVALUE_REFERENCES - // Emulate a move constructor and a move assignment operator if rvalue - // references are not supported. - - private: - // A proxy object to emulate a move constructor. - // It is private to make it impossible call operator Proxy directly. - struct Proxy { - FILE *file; - }; - -public: - // A "move constructor" for moving from a temporary. - buffered_file(Proxy p) FMT_NOEXCEPT : file_(p.file) {} - - // A "move constructor" for moving from an lvalue. - buffered_file(buffered_file &f) FMT_NOEXCEPT : file_(f.file_) { - f.file_ = FMT_NULL; - } - - // A "move assignment operator" for moving from a temporary. - buffered_file &operator=(Proxy p) { - close(); - file_ = p.file; - return *this; - } - - // A "move assignment operator" for moving from an lvalue. - buffered_file &operator=(buffered_file &other) { - close(); - file_ = other.file_; - other.file_ = FMT_NULL; - return *this; - } - - // Returns a proxy object for moving from a temporary: - // buffered_file file = buffered_file(...); - operator Proxy() FMT_NOEXCEPT { - Proxy p = {file_}; - file_ = FMT_NULL; - return p; - } - -#else private: buffered_file(const buffered_file &) = delete; void operator=(const buffered_file &) = delete; @@ -199,7 +155,6 @@ public: other.file_ = FMT_NULL; return *this; } -#endif // Opens a file. FMT_API buffered_file(cstring_view filename, cstring_view mode); @@ -251,50 +206,6 @@ class file { // Opens a file and constructs a file object representing this file. FMT_API file(cstring_view path, int oflag); -#if !FMT_USE_RVALUE_REFERENCES - // Emulate a move constructor and a move assignment operator if rvalue - // references are not supported. - - private: - // A proxy object to emulate a move constructor. - // It is private to make it impossible call operator Proxy directly. - struct Proxy { - int fd; - }; - - public: - // A "move constructor" for moving from a temporary. - file(Proxy p) FMT_NOEXCEPT : fd_(p.fd) {} - - // A "move constructor" for moving from an lvalue. - file(file &other) FMT_NOEXCEPT : fd_(other.fd_) { - other.fd_ = -1; - } - - // A "move assignment operator" for moving from a temporary. - file &operator=(Proxy p) { - close(); - fd_ = p.fd; - return *this; - } - - // A "move assignment operator" for moving from an lvalue. - file &operator=(file &other) { - close(); - fd_ = other.fd_; - other.fd_ = -1; - return *this; - } - - // Returns a proxy object for moving from a temporary: - // file f = file(...); - operator Proxy() FMT_NOEXCEPT { - Proxy p = {fd_}; - fd_ = -1; - return p; - } - -#else private: file(const file &) = delete; void operator=(const file &) = delete; @@ -310,7 +221,6 @@ class file { other.fd_ = -1; return *this; } -#endif // Destroys the object closing the file it represents if any. FMT_API ~file() FMT_DTOR_NOEXCEPT; @@ -410,12 +320,4 @@ class Locale { #endif // FMT_LOCALE FMT_END_NAMESPACE -#if !FMT_USE_RVALUE_REFERENCES -namespace std { -// For compatibility with C++98. -inline fmt::buffered_file &move(fmt::buffered_file &f) { return f; } -inline fmt::file &move(fmt::file &f) { return f; } -} -#endif - #endif // FMT_POSIX_H_ diff --git a/test/mock-allocator.h b/test/mock-allocator.h index 58e157a5..fc393b26 100644 --- a/test/mock-allocator.h +++ b/test/mock-allocator.h @@ -25,37 +25,31 @@ class AllocatorRef { private: Allocator *alloc_; - public: - typedef typename Allocator::value_type value_type; - - explicit AllocatorRef(Allocator *alloc = nullptr) : alloc_(alloc) {} - - AllocatorRef(const AllocatorRef &other) : alloc_(other.alloc_) {} - - AllocatorRef& operator=(const AllocatorRef &other) { - alloc_ = other.alloc_; - return *this; - } - -#if FMT_USE_RVALUE_REFERENCES - private: void move(AllocatorRef &other) { alloc_ = other.alloc_; other.alloc_ = nullptr; } public: - AllocatorRef(AllocatorRef &&other) { - move(other); - } + typedef typename Allocator::value_type value_type; + + explicit AllocatorRef(Allocator *alloc = nullptr) : alloc_(alloc) {} + + AllocatorRef(const AllocatorRef &other) : alloc_(other.alloc_) {} + AllocatorRef(AllocatorRef &&other) { move(other); } AllocatorRef& operator=(AllocatorRef &&other) { assert(this != &other); move(other); return *this; } -#endif + AllocatorRef& operator=(const AllocatorRef &other) { + alloc_ = other.alloc_; + return *this; + } + + public: Allocator *get() const { return alloc_; } value_type* allocate(std::size_t n) { diff --git a/test/util-test.cc b/test/util-test.cc index 46396f79..12500729 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -235,8 +235,6 @@ TEST(MemoryBufferTest, Ctor) { EXPECT_EQ(123u, buffer.capacity()); } -#if FMT_USE_RVALUE_REFERENCES - typedef AllocatorRef< std::allocator > TestAllocator; static void check_move_buffer(const char *str, @@ -304,8 +302,6 @@ TEST(MemoryBufferTest, MoveAssignment) { EXPECT_GT(buffer2.capacity(), 5u); } -#endif // FMT_USE_RVALUE_REFERENCES - TEST(MemoryBufferTest, Grow) { typedef AllocatorRef< MockAllocator > Allocator; typedef basic_memory_buffer Base;