diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/file_reader.cc | 9 | ||||
-rw-r--r-- | examples/file_writer_test.cc | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/examples/file_reader.cc b/examples/file_reader.cc index b096722..a01b7ab 100644 --- a/examples/file_reader.cc +++ b/examples/file_reader.cc @@ -82,7 +82,14 @@ std::unique_ptr<FileReaderInterface> FileReader::Open( return nullptr; } - return file; + // With C++11, to return |file|, an explicit move is required as the return + // type differs from the local variable. Overload resolution isn't guaranteed + // in this case, though some compilers may adopt the C++14 behavior (C++ + // Standard Core Language Issue #1579, Return by converting move + // constructor): + // https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 + // To keep things simple we opt for the following compatible form. + return std::unique_ptr<FileReaderInterface>(file.release()); } // IVF Frame Header format, from https://wiki.multimedia.cx/index.php/IVF diff --git a/examples/file_writer_test.cc b/examples/file_writer_test.cc index 481808c..df5be17 100644 --- a/examples/file_writer_test.cc +++ b/examples/file_writer_test.cc @@ -18,6 +18,7 @@ #include <cstdint> #include <cstring> #include <memory> +#include <new> #include <ostream> #include <string> #include <utility> @@ -64,7 +65,7 @@ const char* const // TODO(tomfinegan): Add a bitdepth arg, and test writing 10 bit frame buffers. std::unique_ptr<DecoderBuffer> GetFakeDecoderBuffer(ImageFormat image_format) { - auto buffer = absl::make_unique<DecoderBuffer>(); + auto buffer = absl::WrapUnique(new (std::nothrow) DecoderBuffer); if (buffer == nullptr) return nullptr; buffer->chroma_sample_position = kChromaSamplePositionUnknown; buffer->image_format = image_format; |