hl2sdk/utils
sigsegv 0edbd27fb8 Backport swap() -> V_swap() rename to avoid C++11 ADL ambiguity errors
The swap() function provided in the MathLib header was renamed to V_swap in recent Source SDK versions (e.g. 2013) to avoid causing ambiguity problems with std::swap(). But older SDK versions (such as TF2) lack this change, as they predate it.

The ambiguity between MathLib's swap() and std::swap() causes considerable problems when using newer features of C++ (such as std::unique_ptr) which internally call swap() in an unqualified manner to implement move semantics:

/usr/include/c++/5.2.0/bits/unique_ptr.h:342:6: error: call of overloaded ‘swap(MyType*&, MyType*&)’ is ambiguous
/usr/include/c++/5.2.0/bits/move.h:176:5: note: candidate: void std::swap(_Tp&, _Tp&) [with _Tp = MyType*]
hl2sdk-tf2/public/mathlib/mathlib.h:611:18: note: candidate: void swap(T&, T&) [with T = MyType*]

This patch backports the swap() -> V_swap() rename from the 2013 SDK version to the TF2 SDK version, so that the TF2 SDK can be used in conjunction with C++11 features such as std::unique_ptr without difficulty.

More information on why swap() isn't called in a namespace-qualified manner by standard library functions:
http://en.cppreference.com/w/cpp/language/adl#Notes
2016-01-24 16:44:52 -08:00
..
captioncompiler Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
common Backport swap() -> V_swap() rename to avoid C++11 ADL ambiguity errors 2016-01-24 16:44:52 -08:00
demoinfo Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2. 2011-04-28 01:30:09 -05:00
glview Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
height2normal Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
motionmapper Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
nvtristriplib Added most recent version of unmodified HL2 SDK for Orange Box engine 2008-09-15 01:07:45 -05:00
phonemeextractor Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2. 2011-04-28 01:30:09 -05:00
qc_eyes Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
serverplugin_sample Removed PostClientMessagesSent in sample plugin to match removal on iface (bug 5059, r=DS). 2011-08-22 10:07:25 -04:00
smdlexp Added most recent version of unmodified HL2 SDK for Orange Box engine 2008-09-15 01:07:45 -05:00
tgadiff Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vbsp Backport swap() -> V_swap() rename to avoid C++11 ADL ambiguity errors 2016-01-24 16:44:52 -08:00
vice Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vmpi Added most recent version of unmodified HL2 SDK for Orange Box engine 2008-09-15 01:07:45 -05:00
vprojtomake Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2. 2011-04-28 01:30:09 -05:00
vrad Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2. 2011-04-28 01:30:09 -05:00
vrad_launcher Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vtf2tga Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vtfdiff Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vvis Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
vvis_launcher Modified SDK for GCC 4.2 2008-09-15 02:50:57 -05:00
xwad Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2. 2011-04-28 01:30:09 -05:00