编辑:见评论,这是UB-似乎没有一个“好”的解决方案。
把你的头发包起来
op<<
在一个
namespace std {...}
#include <boost/dynamic_bitset.hpp>
#include <boost/test/unit_test.hpp>
namespace std { // THIS LINE
template <typename T, typename... Rest>
std::ostream& operator<<(std::ostream& os, const std::vector<T, Rest...> &v)
{
os << "[ ";
for ( const T& elem : v )
os << elem << ' ';
os << ']';
return os;
}
} // THIS LINE
typedef boost::dynamic_bitset<> BS;
static const std::vector<BS> foo = { BS(std::string("101")) };
BOOST_AUTO_TEST_CASE( test_foo )
{
BOOST_CHECK_EQUAL( foo, foo );
}
https://godbolt.org/z/xoW-IJ
否则,它不会为您的实现寻找正确的名称空间。非常确定这是ADL:
https://en.cppreference.com/w/cpp/language/adl