c++


Macro to define custom exception type - Bad Practice


Is using a c macro like the below to define an exception bad practice?
#define CUSTOM_EXCEPTION(name, msg) class name : std::exception { \
virtual const char* what() const throw() { \
return #msg; \
} \
};
I kind of like the idea of using a macro, because DRY, but I've heard bad things about using macros making code unmaintainable. Is there a better way to define a simple type macro returning a custom message?

Related Links

Sharing Memory between application and driver
Interfacing C++11 array with Cython
alignas specifier: on the type / on the member data
Why std::vector iterator is invalidated after the erase() call?
Is it always safe to change a C-style cast to a static_cast?
No compiler warnings for uninitialized std::atomic<double>
Is it possible to change an enum class variable's specific type without knowing the original enum class?
gsoap does not serve over both ipv4 and ipv6
Qt Charts - How to display a specific point value on x and y axis?
std::move return and input reference argument
building curl with mingw32 and linking lib file to VS 2015
How to show std::vector in QT properly?
How does compiler(GCC) deal with the access control for C++?
Passing a matrix as a parameter by function call operator overloading
Flip model swap chain doesn't acknowledge menu bar
sdbm hash on multiple bytes simultaneously

Categories

HOME
objective-c
migration
authorization
google-places-api
pstricks
spring-transactions
snapshot
video-processing
appcelerator-titanium
adodb-php
atlassian-sourcetree
pad
firebase-cloud-messaging
apache-felix
python-datetime
django-channels
structured-data
ctype
webcam
wijmo5
neoscms
live
chmod
mpd
pam
get-eventlog
opensaml
state
submenu
lightgallery
powerdesigner
google-tv
initializing
webmin
ngrx-effects
card-flip
gooddata
shieldui
fancytree
mapped-drive
android-device-monitor
libphonenumber
data-processing
cakephp-2.x
orika
sqlitestudio
sp-executesql
ikvm
smartmeter
ngdoc
google-url-shortener
greenlets
itil
rpath
strstream
owner
onbeforeunload
nested-forms
datepart
oql
ionic-view
cts
http-accept-header
r1soft
dsquery
velocity.js
sqlsrv
webots
undefined-symbol
offsetheight
du
spatialite
acl2
nstablecolumn
pig-udf
topological-sort
circular-buffer
google-text-to-speech
worksite-sdk
google-plugin-eclipse
gliffy
spool
wtl
workbench
automapper-3
member
xcode6.1
xcode-instruments
sharepoint-clientobject
impactjs
mathgl
policies
android-x86
svggraph
toplink
nsfontmanager
dbase
postfix-operator
wsimport
eclipse-wtp
ios6.1
slimv
pull-to-refresh
ruby-on-rails-plugins
array-formulas
vp8
static-array
phonetics
getprocaddress
dynamic-content
cocos2d-python
showmodaldialog
blat
codehighlighter
laconica

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App