RESTinio

Classes | Namespaces | Macros | Functions
compiler_features.hpp File Reference

Detection of compiler version and absence of various features. More...

`#include <utility>`

Go to the source code of this file.

## Classes
struct | restinio::static_if_details::static_if_impl< true >
struct | restinio::static_if_details::static_if_impl< false >

## Namespaces
namespace | restinio
namespace | restinio::static_if_details

## Macros
#define | RESTINIO_NODISCARD
#define | RESTINIO_FALLTHROUGH
#define | RESTINIO_ENSURE_NOEXCEPT_CALL(expr)
| A wrapper around static_assert for checking that an expression is noexcept and execution of that expression. More...
#define | RESTINIO_STATIC_ASSERT_NOEXCEPT(expr) static_assert(noexcept(expr), #expr " is expected to be noexcept" )
| A wrapper around static_assert for checking that an expression is noexcept. More...
#define | RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT(expr) static_assert(!noexcept(expr), #expr " is not expected to be noexcept" )
| A wrapper around static_assert for checking that an expression is not noexcept. More...

## Functions
template<bool Condition, typename If_Part , typename Else_Part >
decltype(auto) | restinio::static_if_else (If_Part &&if_part, Else_Part &&else_part)
| An emulation of if constexpr for C++14. More...

## Detailed Description

Detection of compiler version and absence of various features.

Since
  v.0.6.0

Definition in file compiler_features.hpp.

## Macro Definition Documentation

## ◆ RESTINIO_ENSURE_NOEXCEPT_CALL

#define RESTINIO_ENSURE_NOEXCEPT_CALL | ( |  | expr | ) |

Value:
static_assert(noexcept(expr), "this call is expected to be noexcept: " #expr); \
expr

A wrapper around static_assert for checking that an expression is noexcept and execution of that expression.

Usage example:

some_class::~some_class() noexcept {
// We should have a guarantee that this call doesn't throw.
RESTINIO_ENSURE_NOEXCEPT_CALL(m_some_resouce.release());
...
}
RESTINIO_ENSURE_NOEXCEPT_CALL
#define RESTINIO_ENSURE_NOEXCEPT_CALL(expr)
A wrapper around static_assert for checking that an expression is noexcept and execution of that expr...
Definition: compiler_features.hpp:60

Attention
  This macro is a part of RESTinio and is not intended to be uses as a part of public API. It can be changed or remove in some future version without any prior notice.

Since
  v.0.6.0

Definition at line 60 of file compiler_features.hpp.

## ◆ RESTINIO_FALLTHROUGH

#define RESTINIO_FALLTHROUGH

Definition at line 37 of file compiler_features.hpp.

## ◆ RESTINIO_NODISCARD

#define RESTINIO_NODISCARD

Definition at line 33 of file compiler_features.hpp.

## ◆ RESTINIO_STATIC_ASSERT_NOEXCEPT

#define RESTINIO_STATIC_ASSERT_NOEXCEPT | ( |  | expr | ) | static_assert(noexcept(expr), #expr " is expected to be noexcept" )

A wrapper around static_assert for checking that an expression is noexcept.

Usage example:

void remove_appropriate_items_at_front(some_container_t & cnt) noexcept {
RESTINIO_STATIC_ASSERT_NOEXCEPT(cnt.empty());
RESTINIO_STATIC_ASSERT_NOEXCEPT(cnt.front());
RESTINIO_STATIC_ASSERT_NOEXCEPT(cnt.pop_front());
while(!cnt.empty() && some_confitions(cnt.front()) {
// We don't expect exceptions here.
cnt.pop_front();
}
}
RESTINIO_STATIC_ASSERT_NOEXCEPT
#define RESTINIO_STATIC_ASSERT_NOEXCEPT(expr)
A wrapper around static_assert for checking that an expression is noexcept.
Definition: compiler_features.hpp:89

Attention
  This macro is a part of RESTinio and is not intended to be uses as a part of public API. It can be changed or remove in some future version without any prior notice.

Since
  v.0.6.0

Definition at line 89 of file compiler_features.hpp.

## ◆ RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT

#define RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT | ( |  | expr | ) | static_assert(!noexcept(expr), #expr " is not expected to be noexcept" )

A wrapper around static_assert for checking that an expression is not noexcept.

Usage example:

some_class::~some_class() noexcept {
// If that call throws then we have to use try-catch block.
RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT(m_some_resouce.release());
try {
m_some_resouce.release();
}
catch(...) {}
...
}
RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT
#define RESTINIO_STATIC_ASSERT_NOT_NOEXCEPT(expr)
A wrapper around static_assert for checking that an expression is not noexcept.
Definition: compiler_features.hpp:116

Attention
  This macro is a part of RESTinio and is not intended to be uses as a part of public API. It can be changed or remove in some future version without any prior notice.

Since
  v.0.6.0

Definition at line 116 of file compiler_features.hpp.