mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
* translator.h: use bind, equal_to instead of equal_1st_in_pair
and equal_2nd_in_pair * Makefile.am (libsupport_la_SOURCES): remove lyxfunctional.h * lyxfunctional.h: delete file * RadioButtonGroup.C (set): use bind, equal_to instead of equal_2nd_in_pair git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9184 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ab9e55eb69
commit
36bbe54813
@ -1,5 +1,8 @@
|
||||
2004-11-06 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* RadioButtonGroup.C (set): use bind, equal_to instead of
|
||||
equal_2nd_in_pair
|
||||
|
||||
* xformsImage.C (loadableFormats): use bind, equal_to instead of
|
||||
compare_memfun
|
||||
|
||||
|
@ -17,13 +17,15 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include "support/lyxfunctional.h"
|
||||
|
||||
#include "lyx_forms.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using boost::bind;
|
||||
|
||||
using std::endl;
|
||||
using std::equal_to;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -43,7 +45,9 @@ void RadioButtonGroup::set(size_type value) const
|
||||
{
|
||||
ButtonValueMap::const_iterator it =
|
||||
find_if(map.begin(), map.end(),
|
||||
lyx::equal_2nd_in_pair<ButtonValuePair>(value));
|
||||
bind(equal_to<size_type>(),
|
||||
bind(&ButtonValuePair::second, _1),
|
||||
value));
|
||||
|
||||
if (it != map.end()) {
|
||||
fl_set_button(it->first, 1);
|
||||
|
@ -1,9 +1,15 @@
|
||||
2004-11-06 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* translator.h: use bind, equal_to instead of equal_1st_in_pair
|
||||
and equal_2nd_in_pair
|
||||
|
||||
* Makefile.am (libsupport_la_SOURCES): remove lyxfunctional.h
|
||||
* lyxfunctional.h: delete file
|
||||
|
||||
* lyxfunctional.h: delete compare_memfun and helper classes
|
||||
|
||||
* forkedcontr.C (find_pid): use bind, equal_to instead of
|
||||
compare_memfun
|
||||
compare_memfun
|
||||
|
||||
* lyxfunctional.h: delete back_inserter_fun functions and helper
|
||||
classes.
|
||||
|
@ -46,7 +46,6 @@ libsupport_la_SOURCES = \
|
||||
lstrings.C \
|
||||
lstrings.h \
|
||||
lyxalgo.h \
|
||||
lyxfunctional.h \
|
||||
lyxlib.h \
|
||||
lyxmanip.h \
|
||||
lyxtime.C \
|
||||
|
@ -1,67 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file lyxfunctional.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*
|
||||
* \brief Convenient function objects for use with LyX
|
||||
*
|
||||
* This is currently a small collection of small function objects for use
|
||||
* together with std::algorithms.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LYX_FUNCTIONAL_H
|
||||
#define LYX_FUNCTIONAL_H
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
// Functors used in the template.
|
||||
|
||||
///
|
||||
template<typename T>
|
||||
class equal_1st_in_pair {
|
||||
public:
|
||||
///
|
||||
typedef typename T::first_type first_type;
|
||||
///
|
||||
typedef T pair_type;
|
||||
///
|
||||
equal_1st_in_pair(first_type const & value) : value_(value) {}
|
||||
///
|
||||
bool operator() (pair_type const & p) const {
|
||||
return p.first == value_;
|
||||
}
|
||||
private:
|
||||
///
|
||||
first_type const & value_;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
template<typename T>
|
||||
class equal_2nd_in_pair {
|
||||
public:
|
||||
///
|
||||
typedef typename T::second_type second_type;
|
||||
///
|
||||
typedef T pair_type;
|
||||
///
|
||||
equal_2nd_in_pair(second_type const & value) : value_(value) {}
|
||||
///
|
||||
bool operator() (pair_type const & p) const {
|
||||
return p.second == value_;
|
||||
}
|
||||
private:
|
||||
///
|
||||
second_type const & value_;
|
||||
};
|
||||
|
||||
} // end of namespace lyx
|
||||
#endif
|
@ -13,13 +13,13 @@
|
||||
#define TRANSLATOR_H
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "support/lyxfunctional.h"
|
||||
/**
|
||||
* This class template is used to translate between two elements, specifically
|
||||
* it was worked out to translate between an enum and strings when reading
|
||||
@ -62,7 +62,9 @@ public:
|
||||
// For explanation see the next find() function.
|
||||
typename Map::const_iterator it =
|
||||
std::find_if(map.begin(), map.end(),
|
||||
lyx::equal_1st_in_pair<MapPair>(first)
|
||||
boost::bind(std::equal_to<T1>(),
|
||||
boost::bind(&MapPair::first, _1),
|
||||
first)
|
||||
);
|
||||
|
||||
if (it != map.end()) {
|
||||
@ -89,7 +91,9 @@ public:
|
||||
// equal_to(select2nd(pair) , second)
|
||||
typename Map::const_iterator it =
|
||||
std::find_if(map.begin(), map.end(),
|
||||
lyx::equal_2nd_in_pair<MapPair>(second)
|
||||
boost::bind(std::equal_to<T2>(),
|
||||
boost::bind(&MapPair::second, _1),
|
||||
second)
|
||||
);
|
||||
|
||||
if (it != map.end())
|
||||
|
Loading…
Reference in New Issue
Block a user