[C++] C++17 추가 라이브러리 <any>

http://en.cppreference.com/w/cpp/header/any
Standard library header - cppreference.comStandard library header This header is part of the general utility library. Classes Name Description any (C++17) Objects that hold instances of any CopyConstructible type. (class) bad_any_cast (C++17) exception thrown by the value-returning forms of any_cast on a type mismatch (class) Function...en.cppreference.com

any 말 그대로 뭐든지 담을 수 있는 타입이다.

template<class ValueType >
any( ValueType&& value );

생성자는 이렇게 생겼다. 뭐든지 받는다.

처음 보고 타 객체지향 언어의 Object와 같은 방식으로 쓰는 건가 싶었는데 Object같은 자동 타입 변환은 안 된다.

any_cast<바꿀 타입>(any 객체)로 명시적 캐스팅을 해줘야 원래 접근할 수가 있다.

이렇게

type은 저장되어있는 객체의 타입 정보를 type_info 객체로 반환해주는 메소드다.

별건 없다.