From 60f8cc12e2e2dcd7acbd04161b1e4b2d63be8734 Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Thu, 10 May 2018 22:05:21 -0400 Subject: [PATCH] build: switch to C++14 Cleanup core/common.hpp Change-Id: I6566b0224e24716691d5896462aa7613547ed950 Refs: #3076 --- .waf-tools/default-compiler-flags.py | 4 ++-- core/common.hpp | 22 +++++++++++++------ tests/boost-test.hpp | 5 ++--- tests/chunks/aimd-rtt-estimator.t.cpp | 2 -- tests/chunks/consumer.t.cpp | 1 - tests/dump/ndndump.t.cpp | 12 +++++----- tests/identity-management-fixture.hpp | 6 ++--- tests/test-common.hpp | 10 +++------ tools/chunks/catchunks/aimd-rtt-estimator.cpp | 1 - tools/chunks/catchunks/data-fetcher.hpp | 10 ++++----- tools/chunks/catchunks/pipeline-interests.hpp | 6 ++--- tools/dump/ndndump.cpp | 10 +++------ tools/peek/ndn-poke.cpp | 2 ++ tools/ping/server/ping-server.cpp | 6 +++-- 14 files changed, 46 insertions(+), 51 deletions(-) diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py index e9fdcc6..e690290 100644 --- a/.waf-tools/default-compiler-flags.py +++ b/.waf-tools/default-compiler-flags.py @@ -39,7 +39,7 @@ def configure(conf): conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0) - # General flags are always applied (e.g., selecting C++11 mode) + # General flags are always applied (e.g., selecting C++ language standard) generalFlags = conf.flags.getGeneralFlags(conf) conf.add_supported_cxxflags(generalFlags['CXXFLAGS']) conf.add_supported_linkflags(generalFlags['LINKFLAGS']) @@ -128,7 +128,7 @@ class GccBasicFlags(CompilerFlags): """ def getGeneralFlags(self, conf): flags = super(GccBasicFlags, self).getGeneralFlags(conf) - flags['CXXFLAGS'] += ['-std=c++11'] + flags['CXXFLAGS'] += ['-std=c++14'] return flags def getDebugFlags(self, conf): diff --git a/core/common.hpp b/core/common.hpp index f74c272..8e8c1db 100644 --- a/core/common.hpp +++ b/core/common.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California, +/* + * Copyright (c) 2014-2018, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -38,13 +38,15 @@ #define PROTECTED_WITH_TESTS_ELSE_PRIVATE private #endif -#include #include +#include +#include #include -#include +#include #include -#include +#include #include +#include #include #include @@ -55,20 +57,26 @@ #include #include #include +#include #include #include #include +#include #include -#include -#include #include #include #include #include +#include namespace ndn { +using std::shared_ptr; +using std::unique_ptr; +using std::make_shared; +using std::make_unique; + using std::size_t; using boost::noncopyable; diff --git a/tests/boost-test.hpp b/tests/boost-test.hpp index cd4ccfe..017a0be 100644 --- a/tests/boost-test.hpp +++ b/tests/boost-test.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2015, Regents of the University of California, +/* + * Copyright (c) 2014-2018, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -30,7 +30,6 @@ #pragma GCC system_header #pragma clang system_header -#include #include #include diff --git a/tests/chunks/aimd-rtt-estimator.t.cpp b/tests/chunks/aimd-rtt-estimator.t.cpp index 9241fee..d254985 100644 --- a/tests/chunks/aimd-rtt-estimator.t.cpp +++ b/tests/chunks/aimd-rtt-estimator.t.cpp @@ -28,8 +28,6 @@ #include "tests/test-common.hpp" -#include - namespace ndn { namespace chunks { namespace aimd { diff --git a/tests/chunks/consumer.t.cpp b/tests/chunks/consumer.t.cpp index 3662f24..37e9abe 100644 --- a/tests/chunks/consumer.t.cpp +++ b/tests/chunks/consumer.t.cpp @@ -29,7 +29,6 @@ #include "tests/test-common.hpp" -#include #include #include diff --git a/tests/dump/ndndump.t.cpp b/tests/dump/ndndump.t.cpp index e371fa5..bad4efa 100644 --- a/tests/dump/ndndump.t.cpp +++ b/tests/dump/ndndump.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, University of Memphis. +/* + * Copyright (c) 2014-2018, University of Memphis. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -19,13 +19,11 @@ #include "tools/dump/ndndump.hpp" +#include "tests/identity-management-fixture.hpp" +#include "tests/test-common.hpp" + #include #include -#include - -#include "tests/test-common.hpp" -#include "tests/identity-management-fixture.hpp" -#include namespace ndn { namespace dump { diff --git a/tests/identity-management-fixture.hpp b/tests/identity-management-fixture.hpp index fbe5251..a0fac2e 100644 --- a/tests/identity-management-fixture.hpp +++ b/tests/identity-management-fixture.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California. +/* + * Copyright (c) 2014-2018, Regents of the University of California. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -21,8 +21,6 @@ #define NDN_TOOLS_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP #include "tests/test-common.hpp" -#include -#include namespace ndn { namespace tests { diff --git a/tests/test-common.hpp b/tests/test-common.hpp index be0b63d..c0052e2 100644 --- a/tests/test-common.hpp +++ b/tests/test-common.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California, +/* + * Copyright (c) 2014-2018, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -27,14 +27,10 @@ #define NDN_TOOLS_TESTS_TEST_COMMON_HPP #include "boost-test.hpp" +#include "core/common.hpp" -#include -#include -#include #include -#include - namespace ndn { namespace tests { diff --git a/tools/chunks/catchunks/aimd-rtt-estimator.cpp b/tools/chunks/catchunks/aimd-rtt-estimator.cpp index 5e88f7c..2e1852f 100644 --- a/tools/chunks/catchunks/aimd-rtt-estimator.cpp +++ b/tools/chunks/catchunks/aimd-rtt-estimator.cpp @@ -26,7 +26,6 @@ #include "aimd-rtt-estimator.hpp" #include -#include namespace ndn { namespace chunks { diff --git a/tools/chunks/catchunks/data-fetcher.hpp b/tools/chunks/catchunks/data-fetcher.hpp index 4335ab2..5b66450 100644 --- a/tools/chunks/catchunks/data-fetcher.hpp +++ b/tools/chunks/catchunks/data-fetcher.hpp @@ -1,8 +1,8 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2016, Regents of the University of California, - * Colorado State University, - * University Pierre & Marie Curie, Sorbonne University. +/* + * Copyright (c) 2016-2018, Regents of the University of California, + * Colorado State University, + * University Pierre & Marie Curie, Sorbonne University. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -60,7 +60,7 @@ public: */ static const time::milliseconds MAX_CONGESTION_BACKOFF_TIME; - typedef function FailureCallback; + using FailureCallback = std::function; /** * @brief instantiate a DataFetcher object and start fetching data diff --git a/tools/chunks/catchunks/pipeline-interests.hpp b/tools/chunks/catchunks/pipeline-interests.hpp index 90fd76a..30ff2a0 100644 --- a/tools/chunks/catchunks/pipeline-interests.hpp +++ b/tools/chunks/catchunks/pipeline-interests.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2016-2017, Regents of the University of California, + * Copyright (c) 2016-2018, Regents of the University of California, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University. * @@ -49,8 +49,8 @@ namespace chunks { class PipelineInterests { public: - using DataCallback = function; - using FailureCallback = function; + using DataCallback = std::function; + using FailureCallback = std::function; /** * @brief create a PipelineInterests service diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp index e6cfc6a..1fec4f1 100644 --- a/tools/dump/ndndump.cpp +++ b/tools/dump/ndndump.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2014-2017, Regents of the University of California. +/* + * Copyright (c) 2014-2018, Regents of the University of California. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License along with * ndn-tools, e.g., in COPYING.md file. If not, see . */ -/** +/* * Copyright (c) 2011-2014, Regents of the University of California, * * This file is part of ndndump, the packet capture and analysis tool for Named Data @@ -52,13 +52,9 @@ namespace dump { #include -#include - #include #include -#include -#include #include #include diff --git a/tools/peek/ndn-poke.cpp b/tools/peek/ndn-poke.cpp index ceb49b3..7a1eb7b 100644 --- a/tools/peek/ndn-poke.cpp +++ b/tools/peek/ndn-poke.cpp @@ -27,6 +27,8 @@ #include "core/version.hpp" +#include + #include namespace ndn { diff --git a/tools/ping/server/ping-server.cpp b/tools/ping/server/ping-server.cpp index 08d17bf..0a94d0f 100644 --- a/tools/ping/server/ping-server.cpp +++ b/tools/ping/server/ping-server.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/** - * Copyright (c) 2015, Arizona Board of Regents. +/* + * Copyright (c) 2015-2018, Arizona Board of Regents. * * This file is part of ndn-tools (Named Data Networking Essential Tools). * See AUTHORS.md for complete list of ndn-tools authors and contributors. @@ -22,6 +22,8 @@ #include "ping-server.hpp" +#include + namespace ndn { namespace ping { namespace server {