Browse Source

MSVC 2013 compatibility: work around bug with move-only types in vector.

The std::vector implementation somehow wants to copy the data even if
the type is move-only.
Vladimír Vondruš 12 years ago
parent
commit
34ece127bc
  1. 12
      src/Magnum/Text/AbstractFontConverter.cpp

12
src/Magnum/Text/AbstractFontConverter.cpp

@ -40,8 +40,9 @@ AbstractFontConverter::AbstractFontConverter() = default;
AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, std::string plugin): PluginManager::AbstractPlugin(manager, std::move(plugin)) {} AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, std::string plugin): PluginManager::AbstractPlugin(manager, std::move(plugin)) {}
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const { std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const {
/* MSVC 2013 complains about deleted Array copy constructor if {} is used */
CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData), CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData),
"Text::AbstractFontConverter::exportFontToData(): feature not supported", {}); "Text::AbstractFontConverter::exportFontToData(): feature not supported", (std::vector<std::pair<std::string, Containers::Array<unsigned char>>>{}));
return doExportFontToData(font, cache, filename, uniqueUnicode(characters)); return doExportFontToData(font, cache, filename, uniqueUnicode(characters));
} }
@ -52,8 +53,9 @@ std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFo
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif #endif
{ {
/* MSVC 2013 complains about deleted Array copy constructor if {} is used */
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & Feature::MultiFile),
"Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {}); "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", (std::vector<std::pair<std::string, Containers::Array<unsigned char>>>{}));
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> out; std::vector<std::pair<std::string, Containers::Array<unsigned char>>> out;
out.emplace_back(filename, std::move(doExportFontToSingleData(font, cache, characters))); out.emplace_back(filename, std::move(doExportFontToSingleData(font, cache, characters)));
@ -119,15 +121,17 @@ bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& c
} }
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const {
/* MSVC 2013 complains about deleted Array copy constructor if {} is used */
CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData), CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData),
"Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported", {}); "Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported", (std::vector<std::pair<std::string, Containers::Array<unsigned char>>>{}));
return doExportGlyphCacheToData(cache, filename); return doExportGlyphCacheToData(cache, filename);
} }
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const {
/* MSVC 2013 complains about deleted Array copy constructor if {} is used */
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & Feature::MultiFile),
"Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", {}); "Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", (std::vector<std::pair<std::string, Containers::Array<unsigned char>>>{}));
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> out; std::vector<std::pair<std::string, Containers::Array<unsigned char>>> out;
out.emplace_back(filename, std::move(doExportGlyphCacheToSingleData(cache))); out.emplace_back(filename, std::move(doExportGlyphCacheToSingleData(cache)));

Loading…
Cancel
Save