id summary reporter owner description type status milestone component version severity resolution keywords cc 10825 Undefined stream insertion operator in boost::optional . amit.abhash@… akrzemi1 "I get undefined reference error while using boost::optional. Following code can be used to reproduce the error: {{{#!c++ #include #include void print_optional(int type) { boost::optional value; if (type == 1) { value = boost::optional(1000); } std::cout << value; } int main() { print_optional(1); } test_opt.cpp:(.text+0x64): undefined reference to `std::basic_ostream >& boost::operator<< , int>(std::basic_ostream >&, boost::optional const&)' collect2: error: ld returned 1 exit status }}} We are getting this because starting boost-1.56, stream insertion operator is declared in '''optional.hpp''' but not defined: {{{#!c++ // Forward declaration to prevent operator safe-bool from being used. template std::basic_ostream& operator<<(std::basic_ostream& out, optional const& v); // There is no definition of this function. }}} '''Possible Solution''' Adding following code fixed this issue for me: {{{#!c++ namespace boost { template std::basic_ostream& operator<<(std::basic_ostream& out, optional const& v) { if (v) { out << *v; } return out; } } }}}" Bugs closed Boost 1.58.0 optional Boost 1.56.0 Problem fixed undefined stream insertion operator kumaram@…