Наблюдаю какой-то странный глюк.
boost 1.51
VC2010 (на VC2012 не воспроизводится); дебаг, релиз — не имеет значения
#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
int main()
{
cout << boost::filesystem::path(L"abcd") << endl; // "abcd"
cout << boost::filesystem::path(L"abc") << endl; // "abc"
wcout.imbue(std::locale(".866")); // иначе тупо схватим failbit
wcout << boost::filesystem::path(L"abcd") << endl; // "abcd"
wcout << boost::filesystem::path(L"abc") << endl; // BabcB
}
Почему-то при выводе в wcout путей длиной от 0 до 3 значение кавычки — не L'\"' (0x22), а L'B' (0xFF22)
Глючит вот здесь
// path.hpp (654-660)
template <class Char, class Traits>
inline std::basic_ostream<Char, Traits>&
operator<<(std::basic_ostream<Char, Traits>& os, const path& p)
{
return os
<< boost::io::quoted(p.template string<std::basic_string<Char> >(), static_cast<Char>('&') /* третий параметр - неявный */);
}
// quoted_manip.hpp (30-34) - объявление
template <class Char, class Traits, class Alloc>
detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>
quoted(const std::basic_string<Char, Traits, Alloc>& s,
Char escape='\\', Char delim='\"');
// quoted_manip.hpp (161-168) - определение
// manipulator implementation for const std::basic_string&
template <class Char, class Traits, class Alloc>
inline detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char>
quoted(const std::basic_string<Char, Traits, Alloc>& s, Char escape, Char delim) // s = L"abc", escape = L'&', delim = 0xFF22 вместо '\"'
{
return detail::quoted_proxy<std::basic_string<Char, Traits, Alloc> const &, Char> // здесь поставил брекпоинт, внутрь ещё не заходил
(s, escape, delim);
}
Если бы это было только в релизе, я бы погрешил на закидоны оптимизирующего кодогенератора. Но ведь и в дебаге та же фигня.
Расстрел памяти? Но где?
Самое забавное, что в VC2012 не воспроизводится.
02.09.14 20:35: потому что это проблема с компилятором, а не косяк библиотеки — Кодт