C++

関数へのポインターの出力(C++ 編)

fptostr.c を、C++ で書き直してみた。 これで、「CHAR_BIT が 4 の倍数の場合にしか対応していない」という制限は無くなった。 fptostr.cpp #include <bitset> #include <cstring> #include <limits> #include <string> #include <iostream> typedef int (*funcptr_t)(); std::string fptostr(funcptr_t</iostream></string></limits></cstring></bitset>…

STLでメモリーリーク?

question:1174986855 valgrind でメモリーリークが検出されるのは、どうやら std::allocator が原因のようだ。 テストプログラム #include <memory> int main() { std::allocator<int> allocator; int *ip = allocator.allocate(1); allocator.deallocate(ip, 1); } テス</int></memory>…