9 template<class T
> class Delete
{
11 inline void operator ()(T
* & obj
) {
17 template<class T
> void trimVector(std::vector
<T
> & v
) {
18 std::vector
<T
>(v
).swap(v
);
21 template<typename InputIter
, typename Type
> const Type
& setEach(
22 InputIter first
, InputIter last
, const Type
& t
) {
23 for (; first
!= last
; ++first
)
29 inline bool startsWith(const std::string
& str
, const std::string
& prefix
) {
30 return str
.find(prefix
) == 0;
33 inline bool endsWith(const std::string
& str
, const std::string
& postfix
) {
34 size_t n
= postfix
.length();
35 return str
.find(postfix
, str
.length()-n
-1) != std::string::npos
;
39 template<class T
> inline void fill(T
*ar
, const T
& val
, unsigned long n
) {
40 for (unsigned long i
= 0; i
< n
; ++i
)
44 #define SPACES " \t\r\n"
46 inline const std::string
& trim_right(std::string
& s
,
47 const std::string
& t
= SPACES
) {
48 std::string::size_type
i(s
.find_last_not_of(t
) );
49 if (i
!= std::string::npos
)
50 s
.erase(s
.find_last_not_of(t
) + 1);
55 inline const std::string
& trim_left(std::string
& s
,
56 const std::string
& t
= SPACES
) {
57 return s
.erase(0, s
.find_first_not_of(t
) );
60 inline const std::string
& trim(std::string
& s
,
61 const std::string
& t
= SPACES
) {
67 inline void stolower(std::string
& s
) {
68 std::transform(s
.begin(), s
.end(), s
.begin(), tolower
);
71 inline void stoupper(std::string
& s
) {
72 std::transform(s
.begin(), s
.end(), s
.begin(), toupper
);
78 typedef void (Class::*Method
)(void);
81 MethodCall(Method _method
) {
86 void operator()(Class
*c
) {