Loading...
Searching...
No Matches
compiler_features.hpp File Reference

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

`#include <utility>`
`#include <new>`

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_STD_LAUNDER(x) x
#define | RESTINIO_ENSURE_NOEXCEPT_CALL(expr)
| A wrapper around static_assert for checking that an expression is noexcept and execution of that expression.
#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.
#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.

## 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.

## 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:70

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 70 of file compiler_features.hpp.

## RESTINIO_FALLTHROUGH

#define RESTINIO_FALLTHROUGH

Definition at line 40 of file compiler_features.hpp.

## RESTINIO_NODISCARD

#define RESTINIO_NODISCARD

Definition at line 36 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:99

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 99 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:126

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 126 of file compiler_features.hpp.

## RESTINIO_STD_LAUNDER

#define RESTINIO_STD_LAUNDER | ( |  | x | ) | x

Definition at line 47 of file compiler_features.hpp.