10 template<class T
> class Delete
{
12 inline void operator ()(T
* & obj
) {
18 template<class T
> void trimVector(std::vector
<T
> & v
) {
19 std::vector
<T
>(v
).swap(v
);
22 template<typename InputIter
, typename Type
> const Type
& setEach(
23 InputIter first
, InputIter last
, const Type
& t
) {
24 for (; first
!= last
; ++first
)
30 inline bool startsWith(const std::string
& str
, const std::string
& prefix
,
31 std::string::size_type pos
= 0) {
32 return str
.find(prefix
, pos
) == 0;
35 inline bool endsWith(const std::string
& str
, const std::string
& postfix
) {
36 size_t n
= postfix
.length();
37 return str
.find(postfix
, str
.length()-n
-1) != std::string::npos
;
41 template<class T
> inline void fill(T
*ar
, const T
& val
, unsigned long n
) {
42 for (unsigned long i
= 0; i
< n
; ++i
)
46 #define SPACES " \t\r\n"
48 inline const std::string
& trim_right(std::string
& s
,
49 const std::string
& t
= SPACES
) {
50 std::string::size_type
i(s
.find_last_not_of(t
) );
51 if (i
!= std::string::npos
)
52 s
.erase(s
.find_last_not_of(t
) + 1);
57 inline const std::string
& trim_left(std::string
& s
,
58 const std::string
& t
= SPACES
) {
59 return s
.erase(0, s
.find_first_not_of(t
) );
62 inline const std::string
& trim(std::string
& s
,
63 const std::string
& t
= SPACES
) {
69 inline void stolower(std::string
& s
) {
70 std::transform(s
.begin(), s
.end(), s
.begin(), tolower
);
73 inline void stoupper(std::string
& s
) {
74 std::transform(s
.begin(), s
.end(), s
.begin(), toupper
);
80 typedef void (Class::*Method
)(void);
83 MethodCall(Method _method
) {
88 void operator()(Class
*c
) {
93 void operator()(Class
& c
) {
101 template<class Class
, class T
>
104 typedef void (Class::*Method
)(T
);
107 MethodCall1(Method _method
, T _x
) {
113 void operator()(Class
*c
) {
123 template<class Class
, class T1
, class T2
>
126 typedef void (Class::*Method
)(T1
,T2
);
129 MethodCall2(Method _method
, T1 _x
, T2 _y
) {
136 void operator()(Class
*c
) {