星期三, 7月 25, 2012

在msbuild中取得system32位置,不分64還是32位元windows

<PropertyGroup>
  <X64SystemDir>$(SystemRoot)\Sysnative</X64SystemDir>
  <X32SystemDir>$(SystemRoot)\System32</X32SystemDir>
</PropertyGroup>

<Choose>
  <When Condition="Exists('$(X64SystemDir)')">
    <PropertyGroup>
      <SystemDir>$(X64SystemDir)</SystemDir>
    </PropertyGroup>
  </When>
  <Otherwise>
    <PropertyGroup>
      <SystemDir>$(X32SystemDir)</SystemDir>
    </PropertyGroup>
  </Otherwise>
</Choose>

星期三, 3月 14, 2012

C++11: make_shared<T>()

Sample:

#include <memory>
#include <iostream>

using namespace std;

class MyClass{
public:
int m_i;
MyClass(int i):m_i(i){  cout << "constructor" << endl;
}
~MyClass(){
cout << "destructor" << endl;
}
};

void _tmain(int argc, _TCHAR* argv[])
{
cout << "enter main" << endl;
auto a = make_shared<MyClass>(10);
cout << a->m_i << endl;
cout << "leave main" << endl;
}


output:



enter main

constructor

10

leave main

destructor