为什么编译错误告诉我 'string' : is not a member of 'std'??

cl781121 2009-03-06 11:14:29
同一个项目,在其他地方用std::string 什么问题都没有,为什么有的地方就会出现这样的错误呢?
...全文
6995 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
WillyWonka 2009-03-09
  • 打赏
  • 举报
回复
jf
做鸡真好吃 2009-03-09
  • 打赏
  • 举报
回复
HF_99 2009-03-09
  • 打赏
  • 举报
回复
#include <string>
using namespace std
长尾巴的悟空 2009-03-06
  • 打赏
  • 举报
回复
是否正确包含string头文件!
wdq0916 2009-03-06
  • 打赏
  • 举报
回复
#include <string>
using namespace std
oyljerry 2009-03-06
  • 打赏
  • 举报
回复
#include <string>
MicrosoftWindow 2009-03-06
  • 打赏
  • 举报
回复
#include <afx.h>
yc_8301 2009-03-06
  • 打赏
  • 举报
回复
顶2楼的。。
#include <string>
using namespace std
yekoufeng 2009-03-06
  • 打赏
  • 举报
回复
#include <string>
using namespace std
当使用.h文件时,相当于在c中调用库函数,使用的是全局命名空间; 不用加using namespace std;

当使用没带.h文件时,该头文件没有定义全局命名空间,要使用namespace std
centos7 tfs部署笔记.txt 环境信息: Docker version 1.8.2-fc22, build cb216be/1.8.2 Fedora release 22 (Twenty Two) Linux localhost.localdomain 4.0.4-301.fc22.x86_64 #1 SMP Thu May 21 13:10:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux docker centos:CentOS Linux release 7.2.1511 (Core) 参考: http://code.taobao.org/p/tfs/wiki/get/ http://my.oschina.net/beiyou/blog/76129?fromerr=bGluCWDI tfs版本:2.2.16 centos:7.2.1511 gcc:4.8.5 # docker run -i -t centos /bin/bash [root@2f60c4bcddfa /]# yum install make automake autoconf libtool gcc gcc-c++ libuuid-devel zlib-devel mysql-devel readline-devel gperftools-devel.x86_64 -y Libraries have been installed in: /usr/local/lib64//lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- /usr/bin/mkdir -p '/usr/local/lib64//include/tbnet' /usr/bin/install -c -m 644 channel.h channelpool.h connection.h controlpacket.h databuffer.h defaultpacketstreamer.h epollsocketevent.h httppacketstreamer.h httprequestpacket.h httpresponsepacket.h iocomponent.h ipacketfactory.h ipackethandler.h ipacketstreamer.h iserveradapter.h packet.h packetqueue.h packetqueuethread.h serversocket.h socketevent.h socket.h stats.h tbnet.h tcpacceptor.h tcpcomponent.h tcpconnection.h transport.h udpacceptor.h udpcomponent.h udpconnection.h connectionmanager.h '/usr/local/lib64//include/tbnet' [root@2f60c4bcddfa tfs_release-2.2.16]# ./configure --prefix=/usr/local/ configure ok make 问题 : serialization.h:575:27: error: conversion to 'char' from 'long int' may alter its value [-Werror=conversion] buff[3] = (v>>32) & 0xFF; ^ serialization.h:576:27: error: conversion to 'char' from 'long int' may alter its value [-Werror=conversion] buff[2] = (v>>40) & 0xFF; ^ serialization.h:577:27: error: conversion to 'char' from 'long int' may alter its value [-Werror=conversion] buff[1] = (v>>48) & 0xFF; ^ serialization.h:578:27: error: conversion to 'char' from 'long int' may alter its value [-Werror=conversion] 解决 [root@2f60c4bcddfa tfs_release-2.2.16]# find -name Makefile | xargs sed -i 's/-Werror//' 问题 : In file included from session_util.cpp:1:0: session_util.h:30:43: 错误:‘int32_t’不是一个类型名 static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); ^ session_util.h:30:51: 错误:ISO C++ 不允许声明无类型的‘app_id’ [-fpermissive] static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); ^ session_util.h:30:65: 错误:‘int64_t’不是一个类型名 static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); ^ session_util.h:30:73: 错误:ISO C++ 不允许声明无类型的‘session_ip’ [-fpermissive] static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); ^ session_util.h:31:68: 错误:‘int32_t’未声明 static int parse_session_id(const std::string& session_id, int32_t& app_id, int64_t& session_ip); ^ session_util.h:31:85: 错误:‘int64_t’未声明 static int parse_session_id(const std::string& session_id, int32_t& app_id, int64_t& session_ip); session_util.cpp:24:10: 错误:‘void tfs::common::SessionUtil::gene_session_id(int32_t, int64_t, std::string&)’的原型不匹配类‘tfs::common::SessionUtil’中的任何一个 void SessionUtil::gene_session_id(const int32_t app_id, const int64_t session_ip, string& session_id) ^ In file included from session_util.cpp:1:0: session_util.h:30:21: 错误:备选为:static void tfs::common::SessionUtil::gene_session_id(int, int, std::string&) static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); ^ session_util.cpp:31:9: 错误:‘int tfs::common::SessionUtil::parse_session_id(const string&, int32_t&, int64_t&)’的原型不匹配类‘tfs::common::SessionUtil’中的任何一个 int SessionUtil::parse_session_id(const string& session_id, int32_t& app_id, int64_t& session_ip) ^ In file included from session_util.cpp:1:0: session_util.h:31:20: 错误:备选为:static int tfs::common::SessionUtil::parse_session_id(const string&, int&, int&) static int parse_session_id(const std::string& session_id, int32_t& app_id, int64_t& session_ip); 解决 [root@localhost tfs_release-2.2.16]# vim src/common/session_util.h 添加 #include <stdint.h> 整体代码如下 #ifndef TFS_COMMON_SESSIONUTIL_H_ #define TFS_COMMON_SESSIONUTIL_H_ #include <string> #include <stdint.h> namespace tfs { namespace common { static const char SEPARATOR_KEY = '-'; class SessionUtil { public: static std::string gene_uuid_str(); static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id); static int parse_session_id(const std::string& session_id, int32_t& app_id, int64_t& session_ip); }; } } #endif //TFS_RCSERVER_SESSIONUUID_H_ 问题: /lib64//lib/libtbsys.a -lrt -lpthread -lm -ldl -lc /usr/bin/ld: cannot find -ljemalloc collect2: error: ld returned 1 exit statu 解决 curl -O http://www.canonware.com/download/jemalloc/jemalloc-4.0.4.tar.bz2 tar -jxvf jemalloc-4.0.4.tar.bz2 cd jemalloc-4.0.4/ && ./configure && make && make install 问题: block_collect.cpp:229:17: 错误:‘abs’不是‘__gnu_cxx’的成员 if (__gnu_cxx::abs(info_.version_ - info.version_) <= VERSION_AGREED_MASK)//version agreed ^ client_request_server.cpp:167:21: error: 'abs' is not a member of '__gnu_cxx' stat[3] = __gnu_cxx::abs(out.size() - block_count); 解决:替换成cstdlib的abs 问题: meta_server_service.cpp:1584:48: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] char* pos = strstr(sub_dir, parents_dir); 解决:添加编译参数-fpermissive [root@localhost tfs_release-2.2.16]# vim src/name_meta_server/Makefile CXXFLAGS = -g -D__STDC_LIMIT_MACROS -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wdeprecated -fpermissive [root@localhost tfs_release-2.2.16]# make Making all in src make[1]: Entering directory `/usr/local/tfs_release-2.2.16/src' Making all in common make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/common' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/common' Making all in message make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/message' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/message' Making all in new_client make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/new_client' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/new_client' Making all in dataserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/dataserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/dataserver' Making all in nameserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/nameserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/nameserver' Making all in adminserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/adminserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/adminserver' Making all in tools make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools' Making all in util make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/util' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/util' Making all in dataserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' Making all in nameserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' Making all in adminserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' Making all in mock make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/mock' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/mock' Making all in transfer make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' Making all in cluster make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools' make[3]: Nothing to be done for `all-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools' Making all in rcserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/rcserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rcserver' Making all in monitor make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/monitor' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/monitor' Making all in name_meta_server make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' Making all in rootserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/rootserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rootserver' Making all in checkserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/checkserver' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/checkserver' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src' make[2]: Nothing to be done for `all-am'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/src' Making all in conf make[1]: Entering directory `/usr/local/tfs_release-2.2.16/conf' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/conf' Making all in scripts make[1]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' Making all in ha make[2]: Entering directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' make[2]: Nothing to be done for `all-am'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' Making all in sql make[1]: Entering directory `/usr/local/tfs_release-2.2.16/sql' Making all in ms make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql/ms' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/ms' Making all in rcs make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql' make[2]: Nothing to be done for `all-am'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[1]: Entering directory `/usr/local/tfs_release-2.2.16' make[1]: Nothing to be done for `all-am'. make[1]: Leaving directory `/usr/local/tfs_release-2.2.16' [root@localhost tfs_release-2.2.16]# make install Making install in src make[1]: Entering directory `/usr/local/tfs_release-2.2.16/src' Making install in common make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/common' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/common' make[3]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/include' /usr/bin/install -c -m 644 define.h cdefine.h lock.h func.h internal.h meta_server_define.h rts_define.h error_msg.h '/usr/local/include' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/common' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/common' Making install in message make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/message' make[2]: Nothing to be done for `install'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/message' Making install in new_client make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/new_client' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/new_client' /usr/bin/mkdir -p '/usr/local/lib' /bin/sh ../../libtool --mode=install /usr/bin/install -c libtfsclient.la libtfsclient_c.la '/usr/local/lib' libtool: install: /usr/bin/install -c .libs/libtfsclient.so.0.0.0 /usr/local/lib/libtfsclient.so.0.0.0 libtool: install: (cd /usr/local/lib && { ln -s -f libtfsclient.so.0.0.0 libtfsclient.so.0 || { rm -f libtfsclient.so.0 && ln -s libtfsclient.so.0.0.0 libtfsclient.so.0; }; }) libtool: install: (cd /usr/local/lib && { ln -s -f libtfsclient.so.0.0.0 libtfsclient.so || { rm -f libtfsclient.so && ln -s libtfsclient.so.0.0.0 libtfsclient.so; }; }) libtool: install: /usr/bin/install -c .libs/libtfsclient.lai /usr/local/lib/libtfsclient.la libtool: install: /usr/bin/install -c .libs/libtfsclient_c.so.0.0.0 /usr/local/lib/libtfsclient_c.so.0.0.0 libtool: install: (cd /usr/local/lib && { ln -s -f libtfsclient_c.so.0.0.0 libtfsclient_c.so.0 || { rm -f libtfsclient_c.so.0 && ln -s libtfsclient_c.so.0.0.0 libtfsclient_c.so.0; }; }) libtool: install: (cd /usr/local/lib && { ln -s -f libtfsclient_c.so.0.0.0 libtfsclient_c.so || { rm -f libtfsclient_c.so && ln -s libtfsclient_c.so.0.0.0 libtfsclient_c.so; }; }) libtool: install: /usr/bin/install -c .libs/libtfsclient_c.lai /usr/local/lib/libtfsclient_c.la libtool: install: /usr/bin/install -c .libs/libtfsclient.a /usr/local/lib/libtfsclient.a libtool: install: chmod 644 /usr/local/lib/libtfsclient.a libtool: install: ranlib /usr/local/lib/libtfsclient.a libtool: install: /usr/bin/install -c .libs/libtfsclient_c.a /usr/local/lib/libtfsclient_c.a libtool: install: chmod 644 /usr/local/lib/libtfsclient_c.a libtool: install: ranlib /usr/local/lib/libtfsclient_c.a libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- make install-exec-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/new_client' tmp_dir=".tfs_tmp_dir";\ for client_lib in libtfsclient.a libtfsclient_c.a; \ do \ cd /usr/local/lib;\ test -d $tmp_dir && rm -rf $tmp_dir;\ mkdir -p $tmp_dir && mv $client_lib $tmp_dir;\ cd $tmp_dir;\ ar x $client_lib;\ rm -f $client_lib;\ for i in *.a ; do\ lib_tmp_dir=".tmp_$i";\ mkdir -p $lib_tmp_dir;\ mv $i $lib_tmp_dir;\ cd $lib_tmp_dir;\ ar x $i;\ cd ../; done;\ ar cru ../$client_lib `find . -name '*.o'`;\ ranlib ../$client_lib;\ chmod 644 ../$client_lib;\ done; \ cd .. && rm -rf $tmp_dir make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/new_client' /usr/bin/mkdir -p '/usr/local/include' /usr/bin/install -c -m 644 tfs_client_api.h tfs_client_capi.h tfs_rc_client_api.h tfs_meta_client_api.h '/usr/local/include' make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/new_client' cd /usr/local/include && \ sed -i 's#common/\(.*\.h\)#\1#g' tfs_client_api.h tfs_client_capi.h tfs_rc_client_api.h tfs_meta_client_api.h && \ sed -i -n -e '/ifdef \+WITH_UNIQUE_STORE/{h;d}' -e '/endif/{x;/ifdef \+WITH_UNIQUE_STORE/d;x;p;d}' -e 'x;/ifdef \+WITH_UNIQUE_STORE/{x;d};x;p' tfs_client_api.h tfs_client_capi.h tfs_rc_client_api.h tfs_meta_client_api.h make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/new_client' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/new_client' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/new_client' Making install in dataserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/dataserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/dataserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c dataserver '/usr/local/bin' libtool: install: /usr/bin/install -c dataserver /usr/local/bin/dataserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/dataserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/dataserver' Making install in nameserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/nameserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/nameserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c nameserver '/usr/local/bin' libtool: install: /usr/bin/install -c nameserver /usr/local/bin/nameserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/nameserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/nameserver' Making install in adminserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/adminserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/adminserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c adminserver '/usr/local/bin' libtool: install: /usr/bin/install -c adminserver /usr/local/bin/adminserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/adminserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/adminserver' Making install in tools make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools' Making install in util make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/util' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/util' make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/util' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/util' Making install in dataserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c clear_file_system ds_client format_file_system read_super_block recover_disk_data_to_cluster recover_sync_file_queue convert_name reload_config read_index_tool read_block_prefix reverse_name modify_super_block tfsping view_local_key gen_block_prefix verify_block_to_dataserver '/usr/local/bin' libtool: install: /usr/bin/install -c clear_file_system /usr/local/bin/clear_file_system libtool: install: /usr/bin/install -c ds_client /usr/local/bin/ds_client libtool: install: /usr/bin/install -c format_file_system /usr/local/bin/format_file_system libtool: install: /usr/bin/install -c read_super_block /usr/local/bin/read_super_block libtool: install: /usr/bin/install -c recover_disk_data_to_cluster /usr/local/bin/recover_disk_data_to_cluster libtool: install: /usr/bin/install -c recover_sync_file_queue /usr/local/bin/recover_sync_file_queue libtool: install: /usr/bin/install -c convert_name /usr/local/bin/convert_name libtool: install: /usr/bin/install -c reload_config /usr/local/bin/reload_config libtool: install: /usr/bin/install -c read_index_tool /usr/local/bin/read_index_tool libtool: install: /usr/bin/install -c read_block_prefix /usr/local/bin/read_block_prefix libtool: install: /usr/bin/install -c reverse_name /usr/local/bin/reverse_name libtool: install: /usr/bin/install -c modify_super_block /usr/local/bin/modify_super_block libtool: install: /usr/bin/install -c tfsping /usr/local/bin/tfsping libtool: install: /usr/bin/install -c view_local_key /usr/local/bin/view_local_key libtool: install: /usr/bin/install -c gen_block_prefix /usr/local/bin/gen_block_prefix libtool: install: /usr/bin/install -c verify_block_to_dataserver /usr/local/bin/verify_block_to_dataserver make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/dataserver' Making install in nameserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c admintool showsyncoplog rmsyncoplog ssm tfstool performance syncbyfile read_syncoplog_header repair_block_info '/usr/local/bin' libtool: install: /usr/bin/install -c admintool /usr/local/bin/admintool libtool: install: /usr/bin/install -c showsyncoplog /usr/local/bin/showsyncoplog libtool: install: /usr/bin/install -c rmsyncoplog /usr/local/bin/rmsyncoplog libtool: install: /usr/bin/install -c ssm /usr/local/bin/ssm libtool: install: /usr/bin/install -c tfstool /usr/local/bin/tfstool libtool: install: /usr/bin/install -c performance /usr/local/bin/performance libtool: install: /usr/bin/install -c syncbyfile /usr/local/bin/syncbyfile libtool: install: /usr/bin/install -c read_syncoplog_header /usr/local/bin/read_syncoplog_header libtool: install: /usr/bin/install -c repair_block_info /usr/local/bin/repair_block_info make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/nameserver' Making install in adminserver make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c adminservertool '/usr/local/bin' libtool: install: /usr/bin/install -c adminservertool /usr/local/bin/adminservertool make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/adminserver' Making install in mock make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/mock' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/mock' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c mock_data_server '/usr/local/bin' libtool: install: /usr/bin/install -c mock_data_server /usr/local/bin/mock_data_server make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/mock' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/mock' Making install in transfer make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c transfer_block split_block_tool compare_crc compare_same_cluster transfer_same_cluster_block compare_same_cluster_ext remove_block verify_file_same_cluster transfer_ge_dirs transfer_logo_tool '/usr/local/bin' libtool: install: /usr/bin/install -c transfer_block /usr/local/bin/transfer_block libtool: install: /usr/bin/install -c split_block_tool /usr/local/bin/split_block_tool libtool: install: /usr/bin/install -c compare_crc /usr/local/bin/compare_crc libtool: install: /usr/bin/install -c compare_same_cluster /usr/local/bin/compare_same_cluster libtool: install: /usr/bin/install -c transfer_same_cluster_block /usr/local/bin/transfer_same_cluster_block libtool: install: /usr/bin/install -c compare_same_cluster_ext /usr/local/bin/compare_same_cluster_ext libtool: install: /usr/bin/install -c remove_block /usr/local/bin/remove_block libtool: install: /usr/bin/install -c verify_file_same_cluster /usr/local/bin/verify_file_same_cluster libtool: install: /usr/bin/install -c transfer_ge_dirs /usr/local/bin/transfer_ge_dirs libtool: install: /usr/bin/install -c transfer_logo_tool /usr/local/bin/transfer_logo_tool make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/transfer' Making install in cluster make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../../libtool --mode=install /usr/bin/install -c sync_by_blk sync_by_log sync_by_file transfer_by_file sync_analyze_tool '/usr/local/bin' libtool: install: /usr/bin/install -c sync_by_blk /usr/local/bin/sync_by_blk libtool: install: /usr/bin/install -c sync_by_log /usr/local/bin/sync_by_log libtool: install: /usr/bin/install -c sync_by_file /usr/local/bin/sync_by_file libtool: install: /usr/bin/install -c transfer_by_file /usr/local/bin/transfer_by_file libtool: install: /usr/bin/install -c sync_analyze_tool /usr/local/bin/sync_analyze_tool make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools/cluster' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools' make[4]: Entering directory `/usr/local/tfs_release-2.2.16/src/tools' make[4]: Nothing to be done for `install-exec-am'. make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/tools' Making install in rcserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/rcserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/rcserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c rcserver '/usr/local/bin' libtool: install: /usr/bin/install -c rcserver /usr/local/bin/rcserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rcserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rcserver' Making install in monitor make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/monitor' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/monitor' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c ha_monitor ns_ping '/usr/local/bin' libtool: install: /usr/bin/install -c ha_monitor /usr/local/bin/ha_monitor libtool: install: /usr/bin/install -c ns_ping /usr/local/bin/ns_ping make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/monitor' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/monitor' Making install in name_meta_server make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c metaserver '/usr/local/bin' libtool: install: /usr/bin/install -c metaserver /usr/local/bin/metaserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/name_meta_server' Making install in rootserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/rootserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/rootserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c rootserver '/usr/local/bin' libtool: install: /usr/bin/install -c rootserver /usr/local/bin/rootserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rootserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/rootserver' Making install in checkserver make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src/checkserver' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src/checkserver' /usr/bin/mkdir -p '/usr/local/bin' /bin/sh ../../libtool --mode=install /usr/bin/install -c checkserver '/usr/local/bin' libtool: install: /usr/bin/install -c checkserver /usr/local/bin/checkserver make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src/checkserver' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src/checkserver' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/src' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/src' make[3]: Nothing to be done for `install-exec-am'. make[3]: Nothing to be done for `install-data-am'. make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/src' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/src' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/src' Making install in conf make[1]: Entering directory `/usr/local/tfs_release-2.2.16/conf' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/conf' make[2]: Nothing to be done for `install-exec-am'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/conf' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/conf' Making install in scripts make[1]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' Making install in ha make[2]: Entering directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[3]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/scripts/ha' /usr/bin/install -c -m 644 authkeys.sh deploy.sh ha.cf NameServer RootServer rsdep.sh nsdep.sh ns.xml rs.xml '/usr/local/scripts/ha' make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/scripts/ha' mv //usr/local/scripts/ha/authkeys.sh //usr/local/scripts/ha/authkeys mv //usr/local/scripts/ha/deploy.sh //usr/local/scripts/ha/deploy mv //usr/local/scripts/ha/nsdep.sh //usr/local/scripts/ha/nsdep mv //usr/local/scripts/ha/rsdep.sh //usr/local/scripts/ha/rsdep chmod u+x //usr/local/scripts/ha/authkeys chmod u+x //usr/local/scripts/ha/deploy chmod u+x //usr/local/scripts/ha/nsdep chmod u+x //usr/local/scripts/ha/rsdep chmod u+x //usr/local/scripts/ha/NameServer chmod u+x //usr/local/scripts/ha/RootServer make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts/ha' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' make[3]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/scripts' /usr/bin/install -c -m 644 stfs.sh tfs.sh start_sync_log.sh sync.sh cs_sync.sh '/usr/local/scripts' make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/scripts' mv //usr/local/scripts/stfs.sh //usr/local/scripts/stfs mv //usr/local/scripts/tfs.sh //usr/local/scripts/tfs mv //usr/local/scripts/sync.sh //usr/local/scripts/sync mv //usr/local/scripts/start_sync_log.sh //usr/local/scripts/start_sync_log mv //usr/local/scripts/cs_sync.sh //usr/local/scripts/cs_sync chmod u+x //usr/local/scripts/stfs chmod u+x //usr/local/scripts/tfs chmod u+x //usr/local/scripts/sync chmod u+x //usr/local/scripts/start_sync_log chmod u+x //usr/local/scripts/cs_sync sed -i 's#\(TFS_HOME=\).*$#\1/usr/local#g' //usr/local/scripts/stfs //usr/local/scripts/tfs make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/scripts' Making install in sql make[1]: Entering directory `/usr/local/tfs_release-2.2.16/sql' Making install in ms make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql/ms' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/sql/ms' make[3]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/sql/ms' /usr/bin/install -c -m 644 create_dir.sql create_file.sql create_table.sql mv_dir.sql mv_file.sql pwrite_file.sql rm_dir.sql rm_file.sql seq_simulator.sql '/usr/local/sql/ms' make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/sql/ms' make[4]: Nothing to be done for `install-data-hook'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/ms' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/ms' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/ms' Making install in rcs make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[3]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/sql/rcs' /usr/bin/install -c -m 644 create_table.sql '/usr/local/sql/rcs' make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[4]: Nothing to be done for `install-data-hook'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql/rcs' make[2]: Entering directory `/usr/local/tfs_release-2.2.16/sql' make[3]: Entering directory `/usr/local/tfs_release-2.2.16/sql' make[3]: Nothing to be done for `install-exec-am'. make install-data-hook make[4]: Entering directory `/usr/local/tfs_release-2.2.16/sql' make[4]: Nothing to be done for `install-data-hook'. make[4]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[3]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[2]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16/sql' make[1]: Entering directory `/usr/local/tfs_release-2.2.16' make[2]: Entering directory `/usr/local/tfs_release-2.2.16' make[2]: Nothing to be done for `install-exec-am'. make[2]: Leaving directory `/usr/local/tfs_release-2.2.16' make[1]: Leaving directory `/usr/local/tfs_release-2.2.16'
这上传的资源中包含一套我工作中常用的模板库,及不需要MFC支持的excel操作接口,导出函数调用栈(dump stack)接口,可以直接用VS2008运行TestCodeLib.sln来根据unit test来了解用法。 ⑴ 需求(requirements) 重量级的BOOST非常强大,但有时候项目中没有引入它,这时候我们需要自己的模板库。 BOOST is very powerful, but some projects have not include BOOST library. So we need out own template type trait library -- it is the responsibility of this lightweight library. 即使BOOST非常强大,但有些常用的功能其也没有,而经常性的代码中又需要这些功能。比如把运行期数据转换为元程序需要的编译期数据。 Even if BOOST is very powerful,it can't still meet all requirements. e.g. convert runtime data into compile period data needed by metaprogramming. /*************************************************************************************************************************************/ ⑵ 益处(advantage) 此泛型库抽象了一些常用的业务需求,可以避免大量的重复工作。 它是完全泛型的并且是类型安全的(没有强制类型转换),如果使用错误将导致编译失败,从而提高了正确率(正确性由编译器保证)。 这个库的很多模板类型推导不需要C++11的支持,这是一个大的优势(VS2010才开始支持C++11)。 this general library draws out some common business and avoid unnecessary repeat work. it is completed general and type-safe(without any type cast), mistake(s) will cause compile failure, so it improves correctness. In this library , type deduce need't C++11's support, it is big advantage. (VS2010 begin to support C++11) /*************************************************************************************************************************************/ ⑶ 用法(usage) 下载这个库后,使用VS打开.\CodeLib\testcase\TestCodeLib\TestCodeLib.sln,直接按F5启动,即可以看到许多单元测试的用法/测试用例的输出。 如果需要使用某功能,可以参考其对应的测试代码的用法。(每个功能文件.\CodeLib\include\MiniMPL\xxx.hpp,都对应一个测试文件.\CodeLib\testcase\MiniMPL\test_xxx.hpp) (这个库的使用及修改是完全自由的,只需要保留文件头中的注释即可) usage: download this library, open .\CodeLib\testcase\TestCodeLib\TestCodeLib.sln with VS,you can see many usage/test output of unit test. every feature has according unit test file, it shows its usage. e.g. .\CodeLib\include\MiniMPL\xxx.hpp has according ".\CodeLib\testcase\MiniMPL\test_xxx.hpp" this library is all free, the only requirement is that you need to keep the comments in header file. /*********************************************************************************************************************************************************/ ⑷ 本库提供的主要功能介绍: major feature in this lib: ◆ [typeTraits.hpp] ★ 测试类型的基本属性,比如IsConst/IsVoliate/IsRef/isAtomType/isBuildInType/isEnumType/IsIterator/IsPointer/isString/isInnerFloat/isArray/IsBaseDerive/.... ★ 转换类型的基本属性,比如AddConst/AddVoliate/AddRef/AddPointer,..,RemoveConst/RemoveVoliate/RemoveRef/RemovePointer,... 这类功能是元程序库的基本支持组件,其它库(比如boost)也提供了,但本库时提供的检测属性更多。 ☆ detect type property. e.g.IsConst/IsVoliate/IsRef/isAtomType/isBuildInType/isEnumType/IsIterator/IsPointer/isString/isInnerFloat/isArray/IsBaseDerive/.... ☆ convert type basic qualifier,e.g. AddConst/AddVoliate/AddRef/AddPointer,..,RemoveConst/RemoveVoliate/RemoveRef/RemovePointer,... get type traits.e.g.const/voliate/ref/isAtomType/isBuildInType/isEnumType/isString/isInnerFloat/isArray/IsBaseDerive/.... It is base support component of metaprogramming system,it is similiar with BOOST , but this lib provide more. ◆ [typeConvert.hpp] ★ 实现类型的修饰符转换。比如让输出参数类型的修饰符(const/voliate/ref/*)和输入参数类型的修饰符一样。 SameConst/SameVoliate/SameRef/SamePointer/SameAllQualifier/RefAdapter 应用场景:存取结构体的某类成员,当输入参数有某种const/voliate/ref修饰符时,通常要求返回值也有类似的修饰符。 ★ 当把"智能指针/stl迭代器/C指针/前三者嵌套"都视为指针时,其内的最终值(非指针值)是一致的,在模板函数中,某些场景需要取得其最终的非指针值。 应用场景:转发模板函数,如 template void transmit(T p) { receive(p); } //void receive(int&); 如果transmit的传入实参p为指针类型(比如smartpointer::iterator>*或者vector::iterator), 但是转发的接收函数receive的形参为非指针类型(比如int&),理论上是可以实现转换的。 Get::finalValue接口提供了这种自动的转: template void transmit(T p) { receive(Get::finalValue(p)); } ☆ Convert type qualifiers,e.g. addConst/removeConst.. , keep same output qualifier (const/voliate/ref/*) with input type. apply scenario: get member of one structure object. ☆ Think "stlSmartptr/StlContainer::iterator/T*" as pointer, their inner non-pointer value is same. in some scenario, the final non-pointer value is needed. e.g. template void transmit(T p) { receive(p); } //void receive(int&); if real paremeter "p" is smartpointer::iterator>* or vector::iterator , but needed parameter by "receive" is int&, in theory it is OK. Get::finalValue provide this conversion: template void transmit(T p) { receive(Get::finalValue(p)); } ◆ [traverseTypeSet.hpp] ★ C++语法不支持模板函数/模板成员函数作为回调函数。本库采用了封装,可以支持模板函数的回调,并且支持最多7个可变参数(可以简易扩充参数个数)。 可以遍历一个TypeList或者枚举值范围CEnumRange,然后以满足条件的类型回调用户的模板函数。 其广泛的应用场景即是把运行期数据以一种非hard-code的方式转化为编译期数据,从而满足元程序对编译期数据的需求。 ☆ C++ doesn't support template-based callback function. this lib package support template-based callback function(MAX 7 various parameters,easy to expand). It can traverse one TypeList or enum value , then call user's template function by suitable type/enum value. This feature converts runtime data into compile data to meet metaprogramming requirement without hard-code way, it is one big advantage. ◆ [functionTraits.hpp] ★ 获取任意类型函数的各种特征,比如函数的所有参数Params_T,返回值类型Return_T,对象类型Object_T(如果是成员函数),第N个参数的类型GetFunctionParam, 这些类型都是包含修饰符(const/voliate/ref)的完整类型。 这些组件对于操作函数非常重要。 ☆ get some traits of any function, include all parameter type "Params_T",return type "Return_T", host type "Object_T"(if member-function) , No.x parameter type "GetFunctionParam". this type include all signature qualifiers. This component is very important for metaprogramming based on function. ◆ 有时候STL的算法并不好用,经常是为了第三个参数需要自己写一个专用的琐碎的小函数。 虽然可以用std的bind或者boost的lambda,但是对于某些嵌套情况,用起来非常麻烦,这个库提供了下面的一些解决方式: sometimes STL algorithm is not good and it needs one traival function object(third parameter) , althrough std::bind/boost::lambda is available, but for some nest case, it is very hard to be used.this library provide below features: [function.hpp] ★ 把既有的多元函数转换为一元函数对象UnaryFunction。它通常应用于泛型(比较/排序/遍历)算法的第三个参数。 ☆ convert existing multi-parameters into unary function, it is general used as 3rd parameter in general algorithm. e.g. stl::for_each [functionobject.hpp] ★ 把一些常用目的的函数封装成函数对象,比如"比较器/测试器" ☆ function object with special abstract targart. e.g. "comparer/Tester" ◆ [functionCreater.hpp] ★ 把多元函数封装为一元函数的帮助函数。(一元函数对象的类型通常不易于书写) ☆ helper function to pack multi-parameters into unary function.(it is hard to write unary function object type) ◆ [paramPackage.hpp] ★ 实现了把任意多个(最多7个,可简易扩充),任意类型的参数封装成一个参数以利于数据传递。 ☆ pack any number parameter (max 7,easy expand) into one parameter . it is easy to transfer. ◆ [classregister.hpp] ★ MFC的动态创建不是泛型的,创造出来的对象必须是CObject的派生类,而且支持的创造方式单一,不够灵活有时候甚至不能满足需求。 本库里提供了一个泛型的动态创建方式,可以以多种灵活的方式甚至用户自定义的方式来匿名动态创建对象,创建的对象基类可以由用户指定(必须存在派生关系)。 ☆ like MFC's DYNAMIC_CREATE, but the one of MFC is not general,the instance MUST be drived from class CObject, MFC dynamic creation has only one create way,sometimes it is not enough。 this library provides general dynamic create way, can create object by multiple ways , even customized way.and base class can be specified by user. ◆ [callbackWorker.hpp] ★ 最易于使用的回调函数是无参数的回调函数。 此功能可以把任意多个参数的多元(成员/非成员)函数封装成一个无参数函数,作为简单的回调函数。 ☆ best callback function is non-parameter function. This feature packs multiple-parameter function into one no-parameter function, it is easy to be used as callback function. ◆ [memberPtr.hpp] ★ 以统一的方式实现了任意级数的结构体成员的存和取,比如多级结构体嵌套。例子:a.m_b.m_c.m_d.....m_x,非常易于在模板设计中使用。 ☆ access any level member of structure object by one unified way. e.g:a.m_b.m_c.m_d.....m_x,it is easy to be used in template componment. ◆ [anyObject.hpp] ★ 任意对象类(CAnyObject)。提供模板化的指针操作符,如果不支持用户指定指针类型,则转换结果为NULL,从而保证正确性。 ☆ package any object(CAnyObject), it operator function is template-based. if it doesn't support conversion, it return NULL. ◆ [dataset.hpp] ★ 把STL容器和经典数组封装成统一的形式,在使用上不再区别对待。对于C数组,将会自动检测越界情况。 ★ 可以使用初始化列表对数组,STL容器进行(反复)初始化。例如:vector a={1,2,3,45,2}; ☆ pack STL container and class array into unified object with several same interfaces. ☆ can initialize array/stl container with initalization list repeated. e.g. vector a={1,2,3,45,2}; ◆ [macroLoop.hpp] ★ 当多条语句的差别仅仅是一个数字时,可以利用提供的循环宏简化成一条宏语句,从而简化书写。用法可参见对应的单元测试例子。 ☆ if only one number is different in multiple statements, can use one macro loop to simplify them (one macro statement) usage refer to unit test. ◆ [mathOperator.hpp] ★ 泛型的数学操作符。"equal/lesser/NotBinary/NotUnary/notEqual/lesserEqual/greater/greaterEqual及交换函数swap/swapif" ☆ general math operator. "equal/lesser/NotBinary/NotUnary/notEqual/lesserEqual/greater/greaterEqual and swap/swapif" /*************************************************************************************************************************************/ ⑸ 感谢及借鉴: 本库中的占位符[placeHolder.hpp]借鉴于boost库,感谢boost库的大师们的灵感。 typelist来自loki库,但是把命名空间Loki改为MiniMPL以避免频繁的命名域切入/切出,感谢Andrei Alexandrescu的精彩演绎与启发. thanks and borrow: Args [placeHolder.h] comes from BOOST::MPL. thanks for BOOST team. typelist comes from loki lib with tiny modification(rename namespace loki to MiniMPL to avoid field switch frequently).thanks for Andrei Alexandrescu

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧