In Visual Studio when trying to compile I get a static_assert, but when I click on that error it takes to to the assert itself and not the offending line.
How to find out which line triggered the static_assert?
I know what you mean, because I too use Visual Studio, but I don't think you're clicking on the right thing.
For example, if you compile this in the IDE:
#include <type_traits>
template <class T> void f1 () { static_assert (std::is_same <T, int>::value, "oh no it isn't"); }
template <class T> void f2 () { f1 <T> (); }
int main ()
{
f2 <long> ();
}
Then you see this in the 'Error List' window:
Error C2338 ... oh no it isn't ... test.cpp(3)
Which isn't very helpful.
However, the information you seek is in the Output window (under 'build'), and if we look in there, we see:
test.cpp
g:\source\tests\test.cpp(3): error C2338: oh no it isn't
g:\source\tests\test.cpp(4): note: see reference to function template instantiation 'void f1<T>(void)' being compiled
with
[
T=long
]
g:\source\tests\test.cpp: note: see reference to function template instantiation 'void f2<long>(void)' being compiled
And there is the 'stack trace' you seek (and you can double-click on things to be taken to the corresponding source line).
Simple as that. Run it at rextester (the only online compiler I know of supporting MSVC). Typical SO downvotes when people don't understand the question.