Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++17 #1164

Merged
merged 18 commits into from
Jan 24, 2022
Merged

C++17 #1164

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clang-tidy-10: namespace & nodiscard
C++17 modernizations that it found:
- `modernize-concat-nested-namespaces`
- `modernize-use-nodiscard`
  • Loading branch information
ax3l committed Jan 24, 2022
commit 7b76370e7cfc93ce75a5e7d5e6f3fd83cc5d1e18
2 changes: 1 addition & 1 deletion examples/8a_benchmark_write_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class TestInput
* m_Seg can be set from input
* exception is when h5 collective mode is on. m_Seg=1
*/
unsigned int GetSeg() const
[[nodiscard]] unsigned int GetSeg() const
{
if (m_Backend == ".h5")
if (auxiliary::getEnvString( "OPENPMD_HDF5_INDEPENDENT", "ON" ) != "ON")
Expand Down
7 changes: 2 additions & 5 deletions src/IO/ADIOS/ADIOS2Auxiliary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

#include <iostream>

namespace openPMD
{
namespace detail
namespace openPMD::detail
{
template< typename T >
std::string
Expand Down Expand Up @@ -258,6 +256,5 @@ namespace detail
throw std::runtime_error( "Unreachable!" );
}
}
} // namespace detail
} // namespace openPMD
} // namespace openPMD::detail
#endif
7 changes: 2 additions & 5 deletions src/IO/ADIOS/ADIOS2PreloadAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
#include <numeric>
#include <type_traits>

namespace openPMD
{
namespace detail
namespace openPMD::detail
{
namespace
{
Expand Down Expand Up @@ -288,7 +286,6 @@ namespace detail
}
return it->second.dt;
}
} // namespace detail
} // namespace openPMD
} // namespace openPMD::detail

#endif // openPMD_HAVE_ADIOS2
5 changes: 1 addition & 4 deletions src/auxiliary/Date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#include <sstream>


namespace openPMD
{
namespace auxiliary
namespace openPMD::auxiliary
{
std::string getDateString( std::string const & format )
{
Expand All @@ -48,5 +46,4 @@ namespace auxiliary

return dateString.str();
}
} // namespace auxiliary
} // namespace openPMD
5 changes: 1 addition & 4 deletions src/auxiliary/Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
#include <system_error>


namespace openPMD
{
namespace auxiliary
namespace openPMD::auxiliary
{
bool
directory_exists(std::string const& path)
Expand Down Expand Up @@ -257,5 +255,4 @@ collective_file_read( std::string const & path, MPI_Comm comm )

#endif

} // namespace auxiliary
} // namespace openPMD
5 changes: 1 addition & 4 deletions src/auxiliary/JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
#include <utility> // std::forward
#include <vector>

namespace openPMD
{
namespace json
namespace openPMD::json
{
TracingJSON::TracingJSON()
: TracingJSON( ParsedConfig{} )
Expand Down Expand Up @@ -597,5 +595,4 @@ namespace json
parseOptions( overwrite, /* considerFiles = */ false ).config );
return res.dump();
}
} // namespace json
} // namespace openPMD
5 changes: 1 addition & 4 deletions src/backend/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
#include "openPMD/backend/Container.hpp"
#include "openPMD/RecordComponent.hpp"

namespace openPMD
{
namespace detail
namespace openPMD::detail
{
template<>
std::vector< std::string > keyAsString< std::string const & >(
Expand Down Expand Up @@ -58,4 +56,3 @@ std::vector< std::string > keyAsString< std::string >(
}
}
}
}
2 changes: 1 addition & 1 deletion src/binding/python/RecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ struct PythonDynamicMemoryView
{
}

pybind11::memoryview currentView() const;
[[nodiscard]] pybind11::memoryview currentView() const;

std::shared_ptr< void > m_dynamicView;
ShapeContainer m_arrayShape;
Expand Down
5 changes: 1 addition & 4 deletions src/helper/list_series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include <string>


namespace openPMD
{
namespace helper
namespace openPMD::helper
{
std::ostream &
listSeries(
Expand Down Expand Up @@ -122,5 +120,4 @@ namespace helper

return out;
}
} // helper
} // openPMD
38 changes: 10 additions & 28 deletions test/AuxiliaryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
using namespace openPMD;


namespace openPMD
{
namespace test
namespace openPMD::test
{
struct TestHelper : public Attributable
{
Expand All @@ -40,7 +38,6 @@ struct TestHelper : public Attributable
writable().IOHandler = createIOHandler(".", Access::CREATE, Format::JSON);
}
};
} // test
} // openPMD


Expand Down Expand Up @@ -142,17 +139,14 @@ TEST_CASE( "string_test", "[auxiliary]" )
REQUIRE("1,2" == join({"1", "2"}, ","));
}

namespace openPMD
{
namespace test
namespace openPMD::test
{
struct S : public TestHelper
{
S()
: TestHelper()
{ }
};
} // test
} // openPMD

TEST_CASE( "container_default_test", "[auxiliary]")
Expand All @@ -168,9 +162,7 @@ TEST_CASE( "container_default_test", "[auxiliary]")
#endif
}

namespace openPMD
{
namespace test
namespace openPMD::test
{
struct structure : public TestHelper
{
Expand All @@ -182,10 +174,9 @@ struct structure : public TestHelper
int int_ = 42;
float float_ = 3.14f;

std::string text() const { return std::get< std::string >(getAttribute("text").getResource()); }
[[nodiscard]] std::string text() const { return std::get< std::string >(getAttribute("text").getResource()); }
structure& setText(std::string newText) { setAttribute("text", newText); return *this; }
};
} // test
} // openPMD

TEST_CASE( "container_retrieve_test", "[auxiliary]" )
Expand Down Expand Up @@ -247,9 +238,7 @@ TEST_CASE( "container_retrieve_test", "[auxiliary]" )
#endif
}

namespace openPMD
{
namespace test
namespace openPMD::test
{
struct Widget : public TestHelper
{
Expand All @@ -261,7 +250,6 @@ struct Widget : public TestHelper
: TestHelper()
{ }
};
} // test
} // openPMD

TEST_CASE( "container_access_test", "[auxiliary]" )
Expand Down Expand Up @@ -308,9 +296,7 @@ TEST_CASE( "attributable_default_test", "[auxiliary]" )
REQUIRE(a.numAttributes() == 0);
}

namespace openPMD
{
namespace test
namespace openPMD::test
{
struct AttributedWidget : public TestHelper
{
Expand All @@ -323,7 +309,6 @@ struct AttributedWidget : public TestHelper
return getAttribute(key).getResource();
}
};
} // test
} // openPMD

TEST_CASE( "attributable_access_test", "[auxiliary]" )
Expand Down Expand Up @@ -356,9 +341,7 @@ TEST_CASE( "attributable_access_test", "[auxiliary]" )
REQUIRE(a.numAttributes() == 1);
}

namespace openPMD
{
namespace test
namespace openPMD::test
{
struct Dotty : public TestHelper
{
Expand All @@ -370,14 +353,13 @@ struct Dotty : public TestHelper
setAtt3("3");
}

int att1() const { return std::get< int >(getAttribute("att1").getResource()); }
double att2() const { return std::get< double >(getAttribute("att2").getResource()); }
std::string att3() const { return std::get< std::string >(getAttribute("att3").getResource()); }
[[nodiscard]] int att1() const { return std::get< int >(getAttribute("att1").getResource()); }
[[nodiscard]] double att2() const { return std::get< double >(getAttribute("att2").getResource()); }
[[nodiscard]] std::string att3() const { return std::get< std::string >(getAttribute("att3").getResource()); }
Dotty& setAtt1(int i) { setAttribute("att1", i); return *this; }
Dotty& setAtt2(double d) { setAttribute("att2", d); return *this; }
Dotty& setAtt3(std::string s) { setAttribute("att3", s); return *this; }
};
} // test
} // openPMD

TEST_CASE( "dot_test", "[auxiliary]" )
Expand Down
2 changes: 1 addition & 1 deletion test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct BackendSelection
std::string backendName;
std::string extension;

inline std::string jsonBaseConfig() const
[[nodiscard]] inline std::string jsonBaseConfig() const
{
return R"({"backend": ")" + backendName + "\"}";
}
Expand Down