I read that C++11 has introduced the concept of attributes for example [[noreturn]]
which is to indicate that the function doesn not return to the caller.
[[noreturn]] void fun()
{
throw std::string("Error!!!");
}
void func()
{
fun();
}
void aTempFunc()
{
try
{
func();
}
catch (std::string &e)
{
std::cout << e << std::endl;
}
}
By looking at the example the reader can understand that the function throws an exception and call will not be returned to the func
function.
I am bit confused to understand what are C++ attributes and why it is required? How a programmer can really make use of these attributes?
Can someone explain in detail. Please correct me if my understanding about the attributes is wrong. Thanks.