-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3rdparty] Update pybind11, set a proper commit for libcoap, add a ty…
…pe_if helper
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#pragma once | ||
#include <utility> | ||
|
||
namespace ossia | ||
{ | ||
|
||
template <typename T, bool Predicate> | ||
struct type_if; | ||
template <typename T> | ||
struct type_if<T, false> | ||
{ | ||
type_if() = default; | ||
type_if(const type_if&) = default; | ||
type_if(type_if&&) = default; | ||
type_if& operator=(const type_if&) = default; | ||
type_if& operator=(type_if&&) = default; | ||
|
||
template <typename U> | ||
type_if(U&&) | ||
{ | ||
} | ||
template <typename U> | ||
T& operator=(U&& u) noexcept | ||
{ | ||
return *this; | ||
} | ||
}; | ||
|
||
template <typename T> | ||
struct type_if<T, true> | ||
{ | ||
[[no_unique_address]] T value; | ||
|
||
type_if() = default; | ||
type_if(const type_if&) = default; | ||
type_if(type_if&&) = default; | ||
type_if& operator=(const type_if&) = default; | ||
type_if& operator=(type_if&&) = default; | ||
|
||
template <typename U> | ||
type_if(U&& other) | ||
: value{std::forward<U>(other)} | ||
{ | ||
} | ||
|
||
operator const T&() const noexcept { return value; } | ||
operator T&() noexcept { return value; } | ||
operator T&&() && noexcept { return std::move(value); } | ||
|
||
template <typename U> | ||
T& operator=(U&& u) noexcept | ||
{ | ||
return value = std::forward<U>(u); | ||
} | ||
}; | ||
} |