I am the OP for the question: Extending a class in which I received an excellent answer. However, as I try to compile the code (reworked slightly for my project) I received the following message (line no. changed to reflect following sample code):
except.h: | 09 | expected nested-name-specifier before ‘handler_t1’
along with many more which seem to stem from this line. I am brand new to C++, and my research into the answer (and the forthcoming problem) has yielded this fact: Microsoft's compiler seems to accept the code, but standards compliant ones do not.
The code as I currently have it is as follows:
#include <vector>
namespace except
{
// several other classes and functions which compile and work already
// (tested and verified) have been snipped out. Entire code is over
// 1000 lines.
class Error_Handler
{
public:
using handler_t1 = bool (*)(except::Logic const&);
std::vector<handler_t1> logic_handlers;
// a lot more removed because the error has already happened ...
}
}
A read through of the code in the linked question indicates to me (with my limited knowledge) that it should all work.
My question therefore is: What do I need to change in this declaration/definition to enable this to compile with gcc (4.6.3 64 bit linux compiling with -std=C++0x)?
GCC 4.6.3 doesn't support C++11 type aliases: using handler_t1 = bool (*)(except::Logic const&);
. Non-template type aliases are equivalent to typedefs: typedef bool (*handler_t1)(except::Logic const&);
. Replace them and see if that helps.
Or even better, upgrade to a more recent compiler version. I believe the regular responders here tend to write to the portion of the language compiled by GCC 4.8.
EDIT: The only other iffy feature I see in that answer is range-based-for, which I believe GCC added support for in 4.6. You should be OK after replacing the type aliases with typedefs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With