dune-common  2.7.0
stdthread.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_COMMON_STDTHREAD_HH
5 #define DUNE_COMMON_STDTHREAD_HH
6 
7 #include <dune/common/unused.hh>
8 
9 namespace Dune
10 {
11 
12  // used internally by assertCallOnce for the actual check
13  void doAssertCallOnce(const char *file, int line, const char *function);
14 
17 
35  inline void assertCallOnce(const char *file = nullptr, int line = -1,
36  const char *function = nullptr)
37  {
38  // make sure to call this only the first time this function is invoked
39  static const bool DUNE_UNUSED works
40  = (doAssertCallOnce(file, line, function), true);
41  }
42 
45 
49 #define DUNE_ASSERT_CALL_ONCE() \
50  ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
51 
52 } // namespace Dune
53 
54 #endif // DUNE_COMMON_STDTHREAD_HH
Dune::doAssertCallOnce
void doAssertCallOnce(const char *file, int line, const char *function)
Definition: stdthread.cc:40
DUNE_UNUSED
#define DUNE_UNUSED
A macro for marking variables that the compiler mistakenly flags as unused, which sometimes happens d...
Definition: unused.hh:16
unused.hh
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
Dune::assertCallOnce
void assertCallOnce(const char *file=nullptr, int line=-1, const char *function=nullptr)
Make sure call_once() works and provide a helpful error message otherwise.
Definition: stdthread.hh:35
Dune
Dune namespace.
Definition: alignedallocator.hh:13