17 #ifndef ZORBA_INTERNAL_ZTD_H
18 #define ZORBA_INTERNAL_ZTD_H
25 #include <zorba/config.h>
73 #define ZORBA_DECL_HAS_MEM_FN(FN_NAME) \
74 template<typename T,typename S> \
75 class has_##FN_NAME : public ::zorba::internal::ztd::sfinae_base { \
76 template<typename SignatureType,SignatureType> struct type_check; \
77 template<class U> static yes& test(type_check<S,&U::FN_NAME>*); \
78 template<class U> static no& test(...); \
80 static bool const value = sizeof( test<T>(0) ) == sizeof( yes ); \
89 namespace has_insertion_operator_impl {
98 template<
typename T>
any_t( T
const& );
134 static std::ostream &s;
178 template<
class StringType>
inline
179 typename StringType::const_pointer
c_str( StringType
const &s ) {
190 inline char const*
c_str(
char const *s ) {
231 template<
typename T>
struct less {
242 template<>
struct less<char const*> :
243 std::binary_function<char const*,char const*,bool>
250 operator()( first_argument_type a, second_argument_type b )
const {
251 return std::strcmp( a, b ) < 0;
261 #define ZORBA_HAS_C_STR(T) \
262 ::zorba::internal::ztd::has_c_str<T,char const* (T::*)() const>::value
264 #define ZORBA_IS_STRING(T) ZORBA_HAS_C_STR(T)
278 ZORBA_TR1_NS::is_same<T_base_const*,char const*>::value
279 || ZORBA_TR1_NS::is_same<T_base_const*,unsigned char const*>::value
280 || ZORBA_TR1_NS::is_same<T_base_const*,signed char const*>::value;
294 template<
typename T>
inline
296 && !ZORBA_TR1_NS::is_pointer<T>::value
300 std::ostringstream o;
316 template<
class T>
inline
337 template<
class T>
inline
340 && has_str<T,std::string (T::*)() const>::value
341 && !has_toString<T,std::string (T::*)() const>::value,
360 template<
class T>
inline
363 && !has_str<T,std::string (T::*)() const>::value
364 && has_toString<T,std::string (T::*)() const>::value,
379 template<
typename T>
inline
381 && !is_c_string<T>::value,
386 return p ?
to_string( *static_cast<T_base_const*>( p ) ) :
"<null>";
397 return s ? s :
"<null>";
407 inline std::string
to_string(
unsigned char const *s ) {
408 return s ?
reinterpret_cast<char const*
>( s ) :
"<null>";
428 struct pointer_conversion {
int valid; };
430 typedef int pointer_conversion::*
type;
447 return &pointer_conversion::valid;
457 template<
typename T>
static
The implementation class that can be used to determine whether a given type T has a global std::ostre...
static std::enable_if< ZORBA_TR1_NS::is_convertible< T, bool >::value, type >::type value_of(T const &value)
Converts the given value to an explicit bool value.
void suppress_all_member_functions_are_private_warning()
std::enable_if<!ZORBA_TR1_NS::is_array< T >::value &&!ZORBA_TR1_NS::is_pointer< T >::value &&has_insertion_operator<T >::value, std::string >::type to_string(T const &t)
StringType::const_pointer c_str(StringType const &s)
#define ZORBA_HAS_C_STR(T)
This dummy class is used to make the matching of the dummy operator<<() worse than the global operato...
ZORBA_DECL_HAS_MEM_FN(c_str)
static type true_value()
Gets the explicit bool value for true.
int pointer_conversion::* type
Helper class for implementing a solution to the "explicit bool conversion" problem.
destroy_delete(destroy_delete< U > const &, typename std::enable_if< ZORBA_TR1_NS::is_convertible< U *, T * >::value >::type *=0)
Copy constructor.
A deleter class that can be used with unique_ptr.
static bool const value
This is true only when the type T has a global operator<<() declared for it.
static type false_value()
Gets the explicit bool value for false.
no operator<<(std::ostream const &, any_t const &)
This dummy operator is matched only when there is no global operator<<() otherwise declared for type ...
void operator()(T *p)
Calls the destroy() member function of the pointed-to object.
result_type operator()(first_argument_type a, second_argument_type b) const
yes & defined(std::ostream &)
This function is matched only when there is a global operator<<() declared for type T because opera...