uni_cast?
-
iiiiih boost! nee lass mal. Bevor mein Programm total aus den Näten platzt lasse ich das lieber.

-
das was da aus boost benutzt wird ist nur minimal und das kannst du auch einfach nachprogrammieren.
MfG
-
Dir zu liebe, ohne Garantie, iplementierungen für is_pointer,remove_const und remove_pointer:
template<class T> struct is_pointer { enum{value=false}; //static const bool, können aber meines wissens nach nicht alle compiler }; template<class T> struct is_pointer<T*> { enum{value=true}; }; template<class T> struct remove_const { typedef T type; }; template<class T> struct remove_const<const T> { typedef T type; }; template<class T> struct remove_pointer { typedef T type; }; template<class T> struct remove_pointer<T*> { typedef T type; };Das sollte dein Programm kein byte größer machen, da nix instanziert wird.
-
@ness:
wie benutzt man das?!?!?!
-
Wenn du z.b. immer sicherstellen willst das du den grund typen bekommst: ( Ohne const, pointer usw )
template < typename Type > struct always_int { typedef typename remove_const< typename remove_pointer< typename remove_const< Type >::type >::type >::type type; }; std::string bool_to_str( bool val ) { return ( val ? "true" : "false" ); } int main() { std::cout << bool_to_str( typeid(always_int< const int * const >::type) == typeid(int) ) << std::endl; std::cout << bool_to_str( typeid(always_int< const int * >::type) == typeid(int) ) << std::endl; std::cout << bool_to_str( typeid(always_int< const int >::type) == typeid(int) ) << std::endl; std::cout << bool_to_str( typeid(always_int< int * const >::type) == typeid(int) ) << std::endl; std::cout << bool_to_str( typeid(always_int< int * >::type) == typeid(int) ) << std::endl; std::cout << bool_to_str( typeid(always_int< int >::type) == typeid(int) ) << std::endl; }Output: true true true true true true
-
Hi,
hab durch zufall diesen Thread gefunden und bin auch sehr an diesem "cast" interessiert. Jedoch habe ich den Code von Otze ausprobiert, doch er geht nicht
Er bringt das Programm zum absturz 
Weiß einer warum?

-
hab durch zufall diesen Thread gefunden und bin auch sehr an diesem "cast" interessiert.
Verarsch doch die Leute nicht. Du bist doch der Threadstarter.
-
Ich versteh ehrlich gesagt nicht, warum ihr diese Unmengen von Code postet.
Was ist mit
mbtowc()
wctomb()
mbstowcs()
wcstombs()oder unter Windows auch
WideCharToMultiByte()
MultiByteToWideChar()Ist natürlich alles C und umständlich zu nutzen, aber hat für mich immer funktioniert.
-
evilissimo schrieb:
std::string bool_to_str( bool val ) { return ( val ? "true" : "false" ); }Das brauchst du nicht wirklich. Dafuer kannst du auch das Flag boolalpha setzen ;).
mfg
v R
-
pZy schrieb:
Ist natürlich alles C und umständlich zu nutzen, aber hat für mich immer funktioniert.
weil es nicht plattformunabhaengig ist?