Created
May 15, 2013 16:39
-
-
Save Fraser999/5585342 to your computer and use it in GitHub Desktop.
Size of boost::optional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
#include <string> | |
#include "boost/optional.hpp" | |
int main() { | |
std::unique_ptr<std::string> ptr(new std::string("A")); | |
boost::optional<std::string> opt_empty; | |
boost::optional<std::string> opt_full("A"); | |
std::cout << "ptr: " << sizeof(ptr) << '\n'; | |
std::cout << "*ptr: " << sizeof(*ptr) << '\n'; | |
std::cout << "opt_empty: " << sizeof(opt_empty) << '\n'; | |
std::cout << "opt_full: " << sizeof(opt_full) << '\n'; | |
std::cout << "*opt_full: " << sizeof(*opt_full) << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MSVC 2012 x64 Release output:
MSVC 2012 x64 Debug output: