Skip to content

Work around `std::vector<std::string>` linker issue

Compare
Choose a tag to compare
@wravery wravery released this 13 Aug 03:18
d296d29

I changed the semantics of the service::schema_exception constructors a bit in order to work around what seems to be a linker bug. Using type inference compiles OK with the syntax service::schema_exception({ std::string(...) }), but it complains that it can't find the definition of std::vector<std::string> if there are no explicitly constructed instances of that type.

Oddly enough, switching to initializer syntax with an extra {} instead of '()' for the constructor (e.g. service::schema_exception { { std::string(...) } }) seems to be enough of a hint to the compiler/linker to include the necessary pieces of std::vector<std::string>. This should be backwards compatible with code that still uses the old syntax, so not a breaking change, but if you continue using that syntax you might encounter the same linker bug (or whatever subtle C++ behavior this is).