37 #ifndef VIGRA_BASICS_HXX 38 #define VIGRA_BASICS_HXX 42 #include "metaprogramming.hxx" 45 #include "mathutil.hxx" 60 #define VIGRA_AS_STRING(T) \ 61 inline std::string asString(T t) \ 63 std::stringstream s; \ 69 VIGRA_AS_STRING(
signed char)
70 VIGRA_AS_STRING(
unsigned char)
71 VIGRA_AS_STRING(
signed short)
72 VIGRA_AS_STRING(
unsigned short)
73 VIGRA_AS_STRING(
signed long)
74 VIGRA_AS_STRING(
unsigned long)
75 VIGRA_AS_STRING(
signed long long)
76 VIGRA_AS_STRING(
unsigned long long)
77 VIGRA_AS_STRING(
signed int)
78 VIGRA_AS_STRING(
unsigned int)
79 VIGRA_AS_STRING(
float)
80 VIGRA_AS_STRING(
double)
81 VIGRA_AS_STRING(
long double)
82 VIGRA_AS_STRING(
void *)
84 #undef VIGRA_AS_STRING 87 std::string operator<<(std::string
const & s, T
const & t)
98 for(
unsigned int k=0; k<s.size(); ++k)
99 s[k] = (std::string::value_type)std::tolower(s[k]);
103 inline std::string
tolower(
const char * s)
105 return tolower(std::string(s));
114 for(
unsigned int k=0; k<s.size(); ++k)
116 if(std::isspace(s[k]))
118 res += (std::string::value_type)std::tolower(s[k]);
135 FinallyImpl(T & destructor)
136 : destructor_(destructor)
149 #define VIGRA_TOKEN_PASTE_IMPL(x, y) x##y 150 #define VIGRA_TOKEN_PASTE(x, y) VIGRA_TOKEN_PASTE_IMPL(x, y) 152 #define VIGRA_FINALLY_IMPL(destructor, counter) \ 153 auto VIGRA_TOKEN_PASTE(_vigra_finally_impl_, counter) = [&]() { destructor; }; \ 154 ::vigra::detail::FinallyImpl<decltype(VIGRA_TOKEN_PASTE(_vigra_finally_impl_, counter))> \ 155 VIGRA_TOKEN_PASTE(_vigra_finally_, counter)(VIGRA_TOKEN_PASTE(_vigra_finally_impl_, counter)) 207 #define VIGRA_FINALLY(destructor) \ 208 VIGRA_FINALLY_IMPL(destructor, __COUNTER__) 212 template <
class T1,
class T2>
213 ostream & operator<<(ostream & s, std::pair<T1, T2>
const & p)
215 s <<
"(" << p.first <<
", " << p.second <<
")";
225 template <
typename TPL,
size_t N,
typename FUNCTOR>
226 struct for_each_in_tuple_impl
228 typedef for_each_in_tuple_impl<TPL, N-1, FUNCTOR> ForEachRecursion;
230 void operator()(TPL && t, FUNCTOR && f)
const 232 ForEachRecursion()(std::forward<TPL>(t), std::forward<FUNCTOR>(f));
233 f(std::get<N-1>(std::forward<TPL>(t)));
237 template <
typename TPL,
typename FUNCTOR>
238 struct for_each_in_tuple_impl<TPL, 0, FUNCTOR>
240 void operator()(TPL && t, FUNCTOR && f)
const 281 template <
typename TPL,
typename FUNCTOR>
284 typedef typename std::decay<TPL>::type UNQUALIFIED_TPL;
285 typedef detail::for_each_in_tuple_impl<TPL, std::tuple_size<UNQUALIFIED_TPL>::value, FUNCTOR> ForEachImpl;
287 ForEachImpl()(std::forward<TPL>(t), std::forward<FUNCTOR>(f));
321 #endif // VIGRA_BASICS_HXX std::string tolower(std::string s)
Definition: utilities.hxx:96
Definition: array_vector.hxx:954
void for_each_in_tuple(TPL &&t, FUNCTOR &&f)
Definition: utilities.hxx:282
doxygen_overloaded_function(template<... > void separableConvolveBlockwise) template< unsigned int N
Separated convolution on ChunkedArrays.
std::string asString(T t)(...)
std::string normalizeString(std::string const &s)
Definition: utilities.hxx:110