I wonder if GCC has a non-standard built-in pre-declaration header somewhere that it uses internally - I'll look around.
<bits/strfwd.h> in GCC and MinGW pre-declares std::string, std::wstring, std::u16string, std::u32string. Though it says:
/** @file bits/stringfwd.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{string}
*/
Based on RobTheBloke's code a few posts up, this is the header I'm going to start using: (works with MinGW 4.7.2)
#ifndef COMMON_SYSTEM_FWDSTRING_H
#define COMMON_SYSTEM_FWDSTRING_H
/*
Forward-declares std::string, StringList, and StringMap.
WARNING: This is non-standard.
*/
namespace std
{
//----------------------------------------------------------------------
// Forward-declare std::string (and std::char_traits, and std::allocator)
template < class T > struct char_traits;
template < typename T > class allocator;
template < typename CharT, typename Traits, typename Alloc = allocator<CharT> > class basic_string;
typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> > u16string;
typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> > u32string;
//----------------------------------------------------------------------
// Forward-declare std::vector.
template < class T, class Alloc > class vector;
//----------------------------------------------------------------------
// Forward-declare std::less, std::pair, and std::map.
template <class T> struct less;
template <class T1, class T2> struct pair;
template < class Key, class T, class Compare, class Alloc > class map;
//----------------------------------------------------------------------
}
typedef std::vector<std::string, std::allocator<std::string> > StringList;
typedef std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string, std::string> > > StringMap;
#endif // COMMON_SYSTEM_FWDSTRING_H
GCC will lets me pre-declare the templated classes, but won't let me have default template arguments, because later when the actual templated class is defined, it complains about "redefinition of default argument", which is why I manually declared std::basic_string<char, char_traits<char>, allocator<char> >, instead of just std::basic_string<char>.