'STL'에 해당되는 글 3건

  1. 2010.09.13 std::vector 포인터
  2. 2010.09.09 STL 그리고 Template
  3. 2010.09.07 win32API(winAPI), MFC, ATL, STL, WTL, OWL 8
Programming/C++ STL2010. 9. 13. 14:02
VC6.0 프로젝트를 VS2010으로 이전하다가, 코드는 아래와 같은데
std::vector<vectoriter>::iterator iter;
            vectoriter *pch = iter;

이런 에러가 발생이 되었다.
 error C2440: '초기화 중' : 'std::_Vector_iterator<_Myvec>'에서 'vectoriter *'(으)로 변환할 수 없습니다.

STL의 vector를 사용하는데, 어짜피 이녀석도 array로 호출은 되지만,
포인터 레벨의 차이인지 에러를 출력한다.
The usual way is &v[0]. (&*v.begin() would probably work too, but I seem to recall there's some fluffy wording in the standard that makes this not 100% reliable)

[링크 : http://stackoverflow.com/questions/1388597/stdvector-and-c-style-arrays]

 vectoriter *pch = &iter[0]; // no error
 vectoriter *pch = &iter; // error
흐음.. vector.begin() 역시 [0]과 같은 의미인것 같으나.. 여전히 템플릿은 머가먼지... OTL

'Programming > C++ STL' 카테고리의 다른 글

C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
C++0x  (0) 2010.09.15
스마트 포인터(smart pointer)  (2) 2010.09.09
C++ 강좌/문법/reference  (4) 2010.09.09
STL 그리고 Template  (0) 2010.09.09
Posted by 구차니
Programming/C++ STL2010. 9. 9. 09:14
STL - Standard Template Library
원래는 SGI 에서 C++ 지원용으로 개발된 템플릿이다.
[링크 : http://www.sgi.com/tech/stl/index.html]

Scott Meyers 가 작성한 Effective STL (200page)
[링크 : http://www.uml.org.cn/c++/pdf/EffectiveSTL.pdf]

Template는 c++ 에서 지원하는 기능으로
함수나 클래스등을 형(type)에 관계없이 작동시키는(generic type - 일반형) 것이라고 한다.

#include <iostream>
 
template <typename T>
const T& max(const T& x, const T& y)
{
  if(y < x)
    return x;
  return y;
}
 
int main()
{
  // This will call max <int> (by argument deduction)
  std::cout << max(3, 7) << std::endl;
  // This will call max<double> (by argument deduction)
  std::cout << max(3.0, 7.0) << std::endl;
  // This type is ambiguous; explicitly instantiate max<double>
  std::cout << max<double>(3, 7.0) << std::endl;
  return 0;
}

[링크 : http://en.wikipedia.org/wiki/Template_%28programming%29]

[링크 : http://en.wikipedia.org/wiki/C%2B%2B_Standard_Library]
[링크 : http://www.iis.sinica.edu.tw/~kathy/vcstl/templates.htm]

'Programming > C++ STL' 카테고리의 다른 글

C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
C++0x  (0) 2010.09.15
std::vector 포인터  (0) 2010.09.13
스마트 포인터(smart pointer)  (2) 2010.09.09
C++ 강좌/문법/reference  (4) 2010.09.09
Posted by 구차니
Programming/ATL WTL COM2010. 9. 7. 16:31
Win32API는 C로 만들어졌음
MFC는 Win32API를 C++로 감쌈(wrapping)

STL은 C++에서 쓰기쉽도록 여러가지 라이브러리를 모아놓은 것
ATL은 COM을 쉽게 쓸수 있도록 만든 것
WTL은 ATL 기반으로 MFC와 ActiveX를 경량화한 것

MFC의 일부는 COM을 지원하도록 설계
ATL은 COM을 지원하도록 전적으로 설계
ActiveX는 ATL이나 MFC로 작성가능

OWL은 borland c++ 을 위한 winAPI framework
boost C++ library는 c++ 를 확장하기 위한 것.


[링크 : http://en.wikipedia.org/wiki/Win32]
[링크 : http://en.wikipedia.org/wiki/Standard_Template_Library]
[링크 : http://en.wikipedia.org/wiki/Windows_Template_Library]
[링크 : http://en.wikipedia.org/wiki/Active_Template_Library]
[링크 : http://en.wikipedia.org/wiki/Microsoft_Foundation_Classes]
[링크 : http://en.wikipedia.org/wiki/Component_Object_Model]
[링크 : http://en.wikipedia.org/wiki/Object_Windows_Library]
[링크 : http://en.wikipedia.org/wiki/Boost_C%2B%2B_Libraries]

[링크 : http://msdn.microsoft.com/en-us/library/k851ext3%28VS.80%29.aspx] MFC/COM
[링크 : http://msdn.microsoft.com/en-us/library/k194shk8%28v=VS.80%29.aspx] MFC/ActiveX

[링크 : http://kanemochi.egloos.com/8848925]
[링크 : http://jacking75.cafe24.com/WTL/Index.htm]
Posted by 구차니