From ad1f0d1f1a195a00cf2ec2848745fdc6186bfbb1 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Mon, 17 Aug 2015 14:40:17 +0200 Subject: o3tl: rename compat_functional header After the cleanup, the stuff there really stands on its own (and the remaining usage of select1st/2nd is more descriptive than lambdas). Change-Id: I0aba131d5dc550189f8130d167dc94167e404540 Reviewed-on: https://gerrit.libreoffice.org/17806 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- include/o3tl/functional.hxx | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 include/o3tl/functional.hxx (limited to 'include/o3tl/functional.hxx') diff --git a/include/o3tl/functional.hxx b/include/o3tl/functional.hxx new file mode 100644 index 000000000000..b1341e2112b7 --- /dev/null +++ b/include/o3tl/functional.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * Lifted and paraphrased from STLport - with additions from Fridrich + * Strba and Thorsten Behrens + */ + +#ifndef INCLUDED_O3TL_COMPAT_FUNCTIONAL_HXX +#define INCLUDED_O3TL_COMPAT_FUNCTIONAL_HXX + +#include + +namespace o3tl +{ +/// Select first value of a pair +template +struct select1st +{ + typedef P argument_type; + typedef typename P::first_type result_type; + const result_type& operator()( const argument_type& cp ) const { + return cp.first; + } +}; + +/// Select second value of a pair +template +struct select2nd +{ + typedef P argument_type; + typedef typename P::second_type result_type; + const result_type& operator()( const argument_type& cp ) const { + return cp.second; + } +}; + +} // namespace o3tl + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit