- Error: lvalue required as unary '&' operand. How to solve it? - 5 Updates
- A C++ library libwy-0.55 is released (for preview) - 2 Updates
- High horse - 4 Updates
- Yet again about my programming philosophy - 1 Update
wyniijj@gmail.com: Jun 06 09:13PM -0700 Alf P. Steinbach於 2018年6月6日星期三 UTC+8下午9時34分20秒寫道: > <url: http://wiki.c2.com/?ThreeStarProgrammer> > Cheers!, > - Alf Basically I use '()' and typedef to avoid such kind of ambiguity. I have a templete class Wy_AtDestroy in my library. https://sourceforge.net/projects/cscall/ It's written from eraly days since learning C++, not modified till now, since I still have no idea how. Probably, a language specialist as you are can shade some light. |
Paavo Helde <myfirstname@osa.pri.ee>: Jun 07 09:02AM +0300 On 6.06.2018 16:34, Alf P. Steinbach wrote: > Eventually you'll advance to three star programmer level, and these > early problems will seem trivial. > <url: http://wiki.c2.com/?ThreeStarProgrammer> Three stars? Are you kidding? I have seen five stars in the code of a coworker (who was desperately trying to figure out why his five-times-nested loops were so slow). |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jun 07 01:30PM +0200 > It's written from eraly days since learning C++, not modified till > now, since I still have no idea how. Probably, a language specialist > as you are can shade some light. It all depends on what the code is for, which is not evident. E.g. if the pointer is meant to point to a dynamic size array, use `std::vector`. Cheers!, - Alf |
wyniijj@gmail.com: Jun 07 05:24AM -0700 Alf P. Steinbach於 2018年6月7日星期四 UTC+8下午7時30分50秒寫道: > `std::vector`. > Cheers!, > - Alf The question was from trying wrapping clib function getaddrinfo(2) I changed my mind to use class (see CSCall/AddrInfo.h). As always, nearly all the classes in the library expose what's wrapped, explicitly violating C++ data encapsulation principle. E.g. WyArray(std::vector), WyStr(std::string) The fact past have been showing 'good'(not bad) to me, I don't know why? Even we all admit data encapsulation is good! |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jun 07 10:49PM +0200 >> Cheers!, >> - Alf > The question was from trying wrapping clib function getaddrinfo(2) Like this: ------------------------------------------------------------------------------ // Source encoding: utf-8 // MinGW g++ build: "g++ main.cpp -std=c++17 -lws2_32 -lntdll" #include <stdlib/all/basics.hpp> // https://github.com/alf-p-steinbach/Wrapped-stdlib using namespace stdlib::ext::hopefully_and_fail; // hopefully, fail using namespace stdlib::ext::type_builders; // ptr_, ref_ #include <winsock2.h> #include <ws2tcpip.h> // getaddrinfo, inet_ntop // Goal: to wrap // // int WSAAPI getaddrinfo( // ptr_<char const> pNodeName, // ptr_<char const> pServiceName, // ptr_<const addrinfo> pHints, // ptr_<ptr<addrinfo>> ppResult // ); #if defined( __GNUC__ ) and not defined( NO_INET_NTOP_FIX ) inline auto inet_ntop( const int family, const ptr_<const in6_addr> address, const ptr_<char> buffer, const socklen_t buffer_size ) { assert( family == AF_INET6 ); (void) family; assert( buffer_size >= INET6_ADDRSTRLEN ); (void) buffer_size; RtlIpv6AddressToStringA( address, buffer ); return buffer; }
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment