⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boost_no_mem_tem_pnts.ipp

📁 C++的一个好库。。。现在很流行
💻 IPP
字号:
//  (C) Joaqu韓 M L髉ez Mu駉z 2004.
//  Use, modification and distribution are subject to the
//  Boost Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/config for most recent version.

//  MACRO:         BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS
//  TITLE:         pointers to members as template arguments
//  DESCRIPTION:   Non-type template parameters which take pointers
//                 to members, fail to work correctly.


namespace boost_no_pointer_to_member_template_parameters{

struct pair
{
   int x, y;

   pair(int x_,int y_)
      : x(x_), y(y_)
      {}
};

template<int pair::* PtrToPairMember>
struct foo
{
   int bar(pair& p)
   { 
      return p.*PtrToPairMember;
   }
};

int test()
{
   pair p(0,1);
   foo<&pair::x> fx;
   foo<&pair::y> fy;

   if((fx.bar(p) != 0) || (fy.bar(p) != 1))
      return 1;
   return 0;
}

}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -