Skip to content

Commit

Permalink
Let Profiling::ProfilingSection(std::string) constructor be explici…
Browse files Browse the repository at this point in the history
…t and nodiscard (kokkos#6690)

* Add nodiscard attribute to Profiling::ProfilingSection

* Make Profiling::ProfilingSection constructor explicit
  • Loading branch information
dalg24 committed Jan 3, 2024
1 parent 4078a0d commit f485cfa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/Kokkos_Profiling_ProfileSection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
namespace Kokkos {
namespace Profiling {

class ProfilingSection {
class [[nodiscard]] ProfilingSection {
public:
ProfilingSection(ProfilingSection const&) = delete;
ProfilingSection& operator=(ProfilingSection const&) = delete;

ProfilingSection(const std::string& sectionName) {
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard) >= 201907
[[nodiscard]]
#endif
explicit ProfilingSection(const std::string& sectionName) {
Kokkos::Profiling::createProfileSection(sectionName, &secID);
}

Expand Down

0 comments on commit f485cfa

Please sign in to comment.