Small C++11 tweaks.
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 22:29:58 +0000 (23:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 22:29:58 +0000 (23:29 +0100)
src/dcp_reader.cc
src/effect.cc
src/subrip_reader.cc

index 663ddf89a4af2f4bfdb132dac0f29000bfaef8f3..0c7a29a90aaa9d564f3f18932c00e305599fbd55 100644 (file)
 #include <dcp/smpte_subtitle_asset.h>
 #include <boost/filesystem.hpp>
 
-using std::cout;
-using std::string;
+using std::dynamic_pointer_cast;
 using std::exception;
+using std::make_shared;
 using std::shared_ptr;
+using std::string;
 using boost::optional;
-using std::dynamic_pointer_cast;
 using namespace sub;
 
 static Time
@@ -52,21 +52,21 @@ DCPReader::DCPReader (boost::filesystem::path file)
        string smpte_error;
 
        try {
-               sc.reset (new dcp::InteropSubtitleAsset (file));
+               sc = make_shared<dcp::InteropSubtitleAsset>(file);
        } catch (exception& e) {
                interop_error = e.what ();
        }
 
        if (!sc) {
                try {
-                       sc.reset (new dcp::SMPTESubtitleAsset (file));
+                       sc = make_shared<dcp::SMPTESubtitleAsset>(file);
                } catch (exception& e) {
                        smpte_error = e.what();
                }
        }
 
        if (!sc) {
-               throw DCPError (String::compose ("Could not read subtitles (%1 / %2)", interop_error, smpte_error));
+               throw DCPError(String::compose("Could not read subtitles (%1 / %2)", interop_error, smpte_error));
        }
 
 
index 57eb8633ee4516e278798f74ae74261f6f1e5cfe..dfdb40b18403895e9646e08744a004b8eda1d844 100644 (file)
@@ -29,7 +29,7 @@ optional<Effect>
 sub::string_to_effect (string s)
 {
        if (s == "none") {
-               return optional<Effect> ();
+               return {};
        } else if (s == "border") {
                return BORDER;
        } else if (s == "shadow") {
index ab10f6868d5de1ac432c724de9367f1b576027b9..8ba7c7ddc51f08f2434541d3d07d9fc6fffd129b 100644 (file)
@@ -73,7 +73,7 @@ SubripReader::read (function<optional<string> ()> get_line)
        rs.vertical_position.reference = TOP_OF_SUBTITLE;
 
        while (true) {
-               optional<string> line = get_line ();
+               auto line = get_line ();
                if (!line) {
                        break;
                }