[vlc-devel] [PATCH] mkv: fixed C++03 restriction regarding IndexFinder

Filip Roséen filip at videolabs.io
Wed Mar 9 13:23:38 CET 2016


It somehow slipped my mind that C++03 disallows local types as
template-arguments, which makes one of the earlier commits invalid when
compiled as C++03.

This patch correctly moves the type in question to the global namespace
(inside an anonymous namespace to not pollute the global linkage scope)
so that everything is 100% legal C++03.
---
 modules/demux/mkv/matroska_segment.cpp | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index d04a7a5..7473668 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -629,6 +629,20 @@ bool matroska_segment_c::Preload( )
     return true;
 }
 
+namespace {
+    struct SeekIndexFinder {
+        SeekIndexFinder( mtime_t mk_time_offset )
+            : _mk_time_offset( mk_time_offset )
+        { }
+
+        bool operator()(mtime_t target, mkv_index_t const& mkv_index) const {
+            return target < mkv_index.i_mk_time + _mk_time_offset;
+        }
+
+        mtime_t _mk_time_offset;
+    };
+}
+
 /* Here we try to load elements that were found in Seek Heads, but not yet parsed */
 bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position )
 {
@@ -810,20 +824,8 @@ void matroska_segment_c::Seek( mtime_t i_mk_date, mtime_t i_mk_time_offset, int6
 
     if ( index_idx() )
     {
-        struct IndexFinder {
-            IndexFinder( mtime_t mk_time_offset )
-                : _mk_time_offset( mk_time_offset )
-            { }
-
-            bool operator()(mtime_t target, mkv_index_t const& mkv_index) const {
-                return target < mkv_index.i_mk_time + _mk_time_offset;
-            }
-
-            mtime_t _mk_time_offset;
-        };
-
         index_it = std::upper_bound (
-          indexes_begin(), indexes_end(), i_mk_date, IndexFinder( i_mk_time_offset )
+          indexes_begin(), indexes_end(), i_mk_date, SeekIndexFinder( i_mk_time_offset )
         );
 
         if (index_it != indexes_begin())
-- 
2.7.2



More information about the vlc-devel mailing list