[vlc-devel] [PATCH] mkv: remove deprecated std function

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Dec 11 15:12:41 CET 2019


On Wed, Dec 11, 2019, at 3:07 PM, Alexandre Janniaux wrote:
> Actually, I was told that bind wasn't really friendly and
> should be replaced by lambda functions. But with lambda
> function it is written like this:
> 
> ```
> diff --git a/modules/demux/mkv/chapters.cpp 
> b/modules/demux/mkv/chapters.cpp
> index 3d69da52df..68a212e259 100644
> --- a/modules/demux/mkv/chapters.cpp
> +++ b/modules/demux/mkv/chapters.cpp
> @@ -147,14 +147,13 @@ bool chapter_item_c::EnterLeaveHelper_ ( bool 
> do_subs,
>      bool f_result = false;     f_result |= std::count_if ( 
> codecs.begin (), codecs.end (),
> -      std::mem_fn (co_cb)
> +      [co_cb](auto codec){ return (codec->*co_cb)(); }
>      );     if ( do_subs )
>      {
> -        using std::placeholders::_1;
>          f_result |= count_if ( sub_chapters.begin (), sub_chapters.end 
> (),
> -          std::bind( std::mem_fn( ch_cb ), _1, true )
> +          [ch_cb](auto sub_chapter){ return 
> (sub_chapter->*ch_cb)(true); }
>          );
>      }
> ```
> 
> What do you prefer?
> 
> Regards,

Hi,

I'm usually rooting for lambdas, but here it seems std::mem_fn is easier to read

Regards,


-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list