Browse Source

move NR_EXPR to macros.hpp

master
Niklas Rosenstein 2 years ago
parent
commit
b3b56fd501
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
2 changed files with 8 additions and 7 deletions
  1. + 0
    - 7
      include/NiklasRosenstein/macros.h
  2. + 8
    - 0
      include/NiklasRosenstein/macros.hpp

+ 0
- 7
include/NiklasRosenstein/macros.h

@ -155,10 +155,3 @@
#elif !defined(NR_PLATFORM)
#warning "Unable to identify this platform, macro NR_PLATFORM stays undefined."
#endif
#ifdef __cplusplus
#define NR_EXPR(expr) ([&]() expr)()
#endif

+ 8
- 0
include/NiklasRosenstein/macros.hpp

@ -112,3 +112,11 @@ namespace niklasrosenstein {
#define NR_MAKE_CONST(ptr) \
static_cast<std::add_const<std::remove_pointer<decltype(ptr)>::type>::type*>(ptr)
#endif
/**
* This macro puts the specified *expr* as the body of a lambda function
* and calls that function immediately. This allows you to create a new
* scope from which you can return and assign the result to a variable.
*/
#define NR_EXPR(expr) ([&]() expr)()

Loading…
Cancel
Save