이것은 불가능합니다. boost::any_cast
은 유형이 포함 된 유형과 다른 경우 캐스트를 거부합니다.
boost::any any_value(value);
void *content = boost::unsafe_any_cast<void *>(&any_value);
는 헤더가 있습니다 : 지원되지 않는 내부 해킹을 사용하고자하는 경우
는 current version of the header은 (그 이름에서 알 수 있듯이이) boost::any_cast
에 의해 수행 유형 검사를 무시 문서화되지 않은 및 지원되지 않는 기능 boost::unsafe_any_cast
있다 이것에 대해 말하기 unsafe_any_cast
:
// Note: The "unsafe" versions of any_cast are not part of the
// public interface and may be removed at any time. They are
// required where we know what type is stored in the any and can't
// use typeid() comparison, e.g., when our types may travel across
// different shared libraries.
이것은 문서화 된 인터페이스의 일부 여야하므로'boost :: any'는'void * '를 사용하는 레거시 코드와 함께 사용될 수 있습니다. 가장 슬픈 것은'std :: experimental :: any'는'unsafe_any_cast'를 가지고 있지 않은 것처럼 보입니다. – alfC