common: remove NDN_CXX_DECL_FINAL/OVERRIDE macros; use C++11 keywords directly
Change-Id: I8a6bc25a17574093addb144e6cdcc21dd24bbce4
Refs: #3599
diff --git a/.waf-tools/compiler-features.py b/.waf-tools/compiler-features.py
index cf41970..39516e6 100644
--- a/.waf-tools/compiler-features.py
+++ b/.waf-tools/compiler-features.py
@@ -43,33 +43,6 @@
features='cxx', mandatory=True):
self.define('HAVE_CXX_FRIEND_TYPENAME_WRAPPER', 1)
-OVERRIDE = '''
-class Base
-{
- virtual void
- f(int a);
-};
-
-class Derived : public Base
-{
- virtual void
- f(int a) override;
-};
-
-class Final : public Derived
-{
- virtual void
- f(int a) final;
-};
-'''
-
-@conf
-def check_override(self):
- if self.check_cxx(msg='Checking for override and final specifiers',
- fragment=OVERRIDE,
- features='cxx', mandatory=False):
- self.define('HAVE_CXX_OVERRIDE_FINAL', 1)
-
STD_TO_STRING = '''
#include <string>
int
@@ -118,6 +91,5 @@
def configure(conf):
conf.check_friend_typename()
- conf.check_override()
conf.check_std_to_string()
conf.check_vector_const_iterators()
diff --git a/docs/code-style.rst b/docs/code-style.rst
index c57fd0a..dff6b86 100644
--- a/docs/code-style.rst
+++ b/docs/code-style.rst
@@ -1126,15 +1126,6 @@
open() override;
};
- ndn-cxx declares ``NDN_CXX_DECL_OVERRIDE`` and ``NDN_CXX_DECL_FINAL`` macros that
- expand to ``override`` and ``final`` if the compiler supports this feature,
- but expand to nothing with older compilers.
- These must be used in place of ``override`` and ``final``,
- so that ndn-cxx remains compatible with older compilers.
-
- ``NDN_CXX_DECL_OVERRIDE`` and ``NDN_CXX_DECL_FINAL`` macros are for ndn-cxx internal use.
- Other projects, if adopting this style guide, should define their own macros if needed.
-
3.31. The recommended way to throw an exception derived from ``std::exception`` is to use
the ``BOOST_THROW_EXCEPTION``
`macro <http://www.boost.org/doc/libs/1_42_0/libs/exception/doc/BOOST_THROW_EXCEPTION.html>`__.
diff --git a/docs/doxygen.conf.in b/docs/doxygen.conf.in
index d3d5b2a..2779491 100644
--- a/docs/doxygen.conf.in
+++ b/docs/doxygen.conf.in
@@ -1923,7 +1923,6 @@
PUBLIC_WITH_TESTS_ELSE_PRIVATE=private \
PROTECTED_WITH_TESTS_ELSE_PRIVATE=private \
VIRTUAL_WITH_TESTS \
- DECL_OVERRIDE=override \
NDN_CXX_KEYCHAIN_REGISTER_PIB \
NDN_CXX_KEYCHAIN_REGISTER_TPM
diff --git a/src/common.hpp b/src/common.hpp
index a51f58d..bc34cbd 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -44,23 +44,9 @@
#define NDN_CXX_PROTECTED_WITH_TESTS_ELSE_PRIVATE private
#endif
-/** \def NDN_CXX_DECL_OVERRIDE
- * \brief expands to 'override' if compiler supports this feature, otherwise expands to nothing
- */
-/** \def NDN_CXX_DECL_FINAL
- * \brief expands to 'final' if compiler supports this feature, otherwise expands to nothing
- */
-#ifdef NDN_CXX_HAVE_CXX_OVERRIDE_FINAL
-#define NDN_CXX_DECL_OVERRIDE override
-#define NDN_CXX_DECL_FINAL final
-#else
-#define NDN_CXX_DECL_OVERRIDE
-#define NDN_CXX_DECL_FINAL
-#endif
-
// require C++11
#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__)
-# error "ndn-cxx applications must be compiled using the C++11 standard"
+# error "ndn-cxx applications must be compiled using the C++11 standard (-std=c++11)"
#endif
#include <algorithm>
@@ -137,7 +123,7 @@
namespace ndn {
using boost::noncopyable;
-}
+} // namespace ndn
#include "util/backports.hpp"
diff --git a/src/management/nfd-control-parameters.hpp b/src/management/nfd-control-parameters.hpp
index 93b2e41..c5f26d3 100644
--- a/src/management/nfd-control-parameters.hpp
+++ b/src/management/nfd-control-parameters.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -97,10 +97,10 @@
wireEncode(EncodingImpl<TAG>& encoder) const;
virtual Block
- wireEncode() const NDN_CXX_DECL_FINAL;
+ wireEncode() const final;
virtual void
- wireDecode(const Block& wire) NDN_CXX_DECL_FINAL;
+ wireDecode(const Block& wire) final;
public: // getters & setters
diff --git a/src/security/pib-memory.hpp b/src/security/pib-memory.hpp
index f21af00..377d52d 100644
--- a/src/security/pib-memory.hpp
+++ b/src/security/pib-memory.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -52,76 +52,76 @@
public: // TpmLocator management
virtual void
- setTpmLocator(const std::string& tpmLocator) NDN_CXX_DECL_OVERRIDE;
+ setTpmLocator(const std::string& tpmLocator) override;
virtual std::string
- getTpmLocator() const NDN_CXX_DECL_OVERRIDE;
+ getTpmLocator() const override;
public: // Identity management
virtual bool
- hasIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
+ hasIdentity(const Name& identity) const override;
virtual void
- addIdentity(const Name& identity) NDN_CXX_DECL_OVERRIDE;
+ addIdentity(const Name& identity) override;
virtual void
- removeIdentity(const Name& identity) NDN_CXX_DECL_OVERRIDE;
+ removeIdentity(const Name& identity) override;
virtual std::set<Name>
- getIdentities() const NDN_CXX_DECL_OVERRIDE;
+ getIdentities() const override;
virtual void
- setDefaultIdentity(const Name& identityName) NDN_CXX_DECL_OVERRIDE;
+ setDefaultIdentity(const Name& identityName) override;
virtual Name
- getDefaultIdentity() const NDN_CXX_DECL_OVERRIDE;
+ getDefaultIdentity() const override;
public: // Key management
virtual bool
- hasKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
+ hasKey(const Name& identity, const name::Component& keyId) const override;
virtual void
- addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey) NDN_CXX_DECL_OVERRIDE;
+ addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey) override;
virtual void
- removeKey(const Name& identity, const name::Component& keyId) NDN_CXX_DECL_OVERRIDE;
+ removeKey(const Name& identity, const name::Component& keyId) override;
virtual PublicKey
- getKeyBits(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
+ getKeyBits(const Name& identity, const name::Component& keyId) const override;
virtual std::set<name::Component>
- getKeysOfIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
+ getKeysOfIdentity(const Name& identity) const override;
virtual void
- setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) NDN_CXX_DECL_OVERRIDE;
+ setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) override;
virtual name::Component
- getDefaultKeyOfIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
+ getDefaultKeyOfIdentity(const Name& identity) const override;
public: // Certificate management
virtual bool
- hasCertificate(const Name& certName) const NDN_CXX_DECL_OVERRIDE;
+ hasCertificate(const Name& certName) const override;
virtual void
- addCertificate(const IdentityCertificate& certificate) NDN_CXX_DECL_OVERRIDE;
+ addCertificate(const IdentityCertificate& certificate) override;
virtual void
- removeCertificate(const Name& certName) NDN_CXX_DECL_OVERRIDE;
+ removeCertificate(const Name& certName) override;
virtual IdentityCertificate
- getCertificate(const Name& certName) const NDN_CXX_DECL_OVERRIDE;
+ getCertificate(const Name& certName) const override;
virtual std::set<Name>
- getCertificatesOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
+ getCertificatesOfKey(const Name& identity, const name::Component& keyId) const override;
virtual void
- setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName) NDN_CXX_DECL_OVERRIDE;
+ setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName) override;
virtual IdentityCertificate
- getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
+ getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const override;
private: // Key management
diff --git a/src/security/pib-sqlite3.hpp b/src/security/pib-sqlite3.hpp
index c63fb37..7e867cd 100644
--- a/src/security/pib-sqlite3.hpp
+++ b/src/security/pib-sqlite3.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -61,77 +61,77 @@
public: // TpmLocator management
virtual void
- setTpmLocator(const std::string& tpmLocator) NDN_CXX_DECL_FINAL;
+ setTpmLocator(const std::string& tpmLocator) final;
virtual std::string
- getTpmLocator() const NDN_CXX_DECL_FINAL;
+ getTpmLocator() const final;
public: // Identity management
virtual bool
- hasIdentity(const Name& identity) const NDN_CXX_DECL_FINAL;
+ hasIdentity(const Name& identity) const final;
virtual void
- addIdentity(const Name& identity) NDN_CXX_DECL_FINAL;
+ addIdentity(const Name& identity) final;
virtual void
- removeIdentity(const Name& identity) NDN_CXX_DECL_FINAL;
+ removeIdentity(const Name& identity) final;
virtual std::set<Name>
- getIdentities() const NDN_CXX_DECL_FINAL;
+ getIdentities() const final;
virtual void
- setDefaultIdentity(const Name& identityName) NDN_CXX_DECL_FINAL;
+ setDefaultIdentity(const Name& identityName) final;
virtual Name
- getDefaultIdentity() const NDN_CXX_DECL_FINAL;
+ getDefaultIdentity() const final;
public: // Key management
virtual bool
- hasKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_FINAL;
+ hasKey(const Name& identity, const name::Component& keyId) const final;
virtual void
- addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey) NDN_CXX_DECL_FINAL;
+ addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey) final;
virtual void
- removeKey(const Name& identity, const name::Component& keyId) NDN_CXX_DECL_FINAL;
+ removeKey(const Name& identity, const name::Component& keyId) final;
virtual PublicKey
- getKeyBits(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_FINAL;
+ getKeyBits(const Name& identity, const name::Component& keyId) const final;
virtual std::set<name::Component>
- getKeysOfIdentity(const Name& identity) const NDN_CXX_DECL_FINAL;
+ getKeysOfIdentity(const Name& identity) const final;
virtual void
- setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) NDN_CXX_DECL_FINAL;
+ setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) final;
virtual name::Component
- getDefaultKeyOfIdentity(const Name& identity) const NDN_CXX_DECL_FINAL;
+ getDefaultKeyOfIdentity(const Name& identity) const final;
public: // Certificate Management
virtual bool
- hasCertificate(const Name& certName) const NDN_CXX_DECL_FINAL;
+ hasCertificate(const Name& certName) const final;
virtual void
- addCertificate(const IdentityCertificate& certificate) NDN_CXX_DECL_FINAL;
+ addCertificate(const IdentityCertificate& certificate) final;
virtual void
- removeCertificate(const Name& certName) NDN_CXX_DECL_FINAL;
+ removeCertificate(const Name& certName) final;
virtual IdentityCertificate
- getCertificate(const Name& certName) const NDN_CXX_DECL_FINAL;
+ getCertificate(const Name& certName) const final;
virtual std::set<Name>
- getCertificatesOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_FINAL;
+ getCertificatesOfKey(const Name& identity, const name::Component& keyId) const final;
virtual void
setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId,
- const Name& certName) NDN_CXX_DECL_FINAL;
+ const Name& certName) final;
virtual IdentityCertificate
- getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_FINAL;
+ getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const final;
private:
sqlite3* m_database;
diff --git a/tests/unit-tests/mgmt/dispatcher.t.cpp b/tests/unit-tests/mgmt/dispatcher.t.cpp
index 5458be0..42c3717 100644
--- a/tests/unit-tests/mgmt/dispatcher.t.cpp
+++ b/tests/unit-tests/mgmt/dispatcher.t.cpp
@@ -64,13 +64,13 @@
}
virtual Block
- wireEncode() const NDN_CXX_DECL_FINAL
+ wireEncode() const final
{
return Block(128);
}
virtual void
- wireDecode(const Block& wire) NDN_CXX_DECL_FINAL
+ wireDecode(const Block& wire) final
{
if (wire.type() != 128)
throw tlv::Error("Expecting TLV type 128");
diff --git a/tools/ndnsec/util.hpp b/tools/ndnsec/util.hpp
index 9739dcc..253f170 100644
--- a/tools/ndnsec/util.hpp
+++ b/tools/ndnsec/util.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -139,34 +139,34 @@
}
virtual std::string
- name() const NDN_CXX_DECL_FINAL
+ name() const final
{
return std::string();
}
// There are no tokens for an AccumulatorType
virtual unsigned
- min_tokens() const NDN_CXX_DECL_FINAL
+ min_tokens() const final
{
return 0;
}
virtual unsigned
- max_tokens() const NDN_CXX_DECL_FINAL
+ max_tokens() const final
{
return 0;
}
// Accumulating from different sources is silly.
virtual bool
- is_composing() const NDN_CXX_DECL_FINAL
+ is_composing() const final
{
return false;
}
// Requiring one or more appearances is unlikely.
virtual bool
- is_required() const NDN_CXX_DECL_FINAL
+ is_required() const final
{
return false;
}
@@ -180,7 +180,7 @@
virtual void
parse(boost::any& value_store,
const std::vector<std::string>& new_tokens,
- bool utf8) const NDN_CXX_DECL_FINAL
+ bool utf8) const final
{
if (value_store.empty())
value_store = T();
@@ -191,7 +191,7 @@
* @brief If the option doesn't appear, this is the default value.
*/
virtual bool
- apply_default(boost::any& value_store) const NDN_CXX_DECL_FINAL
+ apply_default(boost::any& value_store) const final
{
value_store = m_default;
return true;
@@ -201,7 +201,7 @@
* @brief Notify the user function with the value of the value store.
*/
virtual void
- notify(const boost::any& value_store) const NDN_CXX_DECL_FINAL
+ notify(const boost::any& value_store) const final
{
const T* val = boost::any_cast<T>(&value_store);
if (m_store)
@@ -210,7 +210,7 @@
#if BOOST_VERSION >= 105900
virtual bool
- adjacent_tokens_only() const NDN_CXX_DECL_FINAL
+ adjacent_tokens_only() const final
{
return false;
}