![]() |
Home | Libraries | People | FAQ | More |
#include <boost/callable_traits/add_transaction_safe.hpp>
template<typename T> using add_transaction_safe_t = //implementation-defined template<typename T> struct add_transaction_safe { using type = add_transaction_safe_t<T>; };
T must be one of the
following:
transaction_safe
specifier to T, if not
already present.
A static_assert always fails
when instantiatic this template if your compiler doesn't support transaction_safe. At the time of this writing,
GCC 6 with the -fgnu-tm is
the only compiler that can use this feature.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/add_transaction_safe.hpp> using boost::callable_traits::add_transaction_safe_t; using not_safe = int(); using safe = int() transaction_safe; using safe_added = add_transaction_safe_t<not_safe>; static_assert(std::is_same<safe, safe_added>{}, ""); int main() {}
#include <boost/callable_traits/remove_transaction_safe.hpp>
template<typename T> using remove_transaction_safe_t = //implementation-defined template<typename T> struct remove_transaction_safe { using type = remove_transaction_safe_t<T>; };
T must be one of the
following:
transaction_safe
specifier from T, if
present.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(substitution failure) |
|
|
(substitution failure) |
|
|
(substitution failure) |
#include <type_traits> #include <boost/callable_traits/remove_transaction_safe.hpp> namespace ct = boost::callable_traits; using ts = int() transaction_safe; using not_ts = int(); using ts_removed = ct::remove_transaction_safe_t<ts>; static_assert(std::is_same<not_ts, ts_removed>{}, ""); int main() {}
#include <boost/callable_traits/is_transaction_safe.hpp>
template<typename T> struct is_transaction_safe; //implementation-defined #ifdef CALLABLE_TRAITS_DISABLE_VARIABLE_TEMPLATES template<typename T> struct is_transaction_safe_v { static_assert(sizeof(T) < 1, "Variable templates not supported on this compiler."); }; #else template<typename T> constexpr bool is_transaction_safe_v = //implementation-defined #endif
std::false_type is inherited by is_transaction_safe<T>
and is aliased by typename is_transaction_safe<T>::type, except when one of the following
criteria is met, in which case std::true_type
would be similarly inherited and aliased:
T is a function
type, function pointer type, function reference type, or member
function pointer type where the function has a transaction_safe
specifier
T is a function
object with a non-overloaded operator(), where the operator() has a transaction_safe
specifier
is_transaction_safe_v<T> is equivalent to is_transaction_safe<T>::value.
Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.
Obviously, this will always be falsy for compilers that don't support transaction_safe at all.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/callable_traits/is_transaction_safe.hpp> namespace ct = boost::callable_traits; struct foo; static_assert(ct::is_transaction_safe<int() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(*)() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(&)() transaction_safe>::value, ""); static_assert(ct::is_transaction_safe<int(foo::*)() const transaction_safe>::value, ""); static_assert(!ct::is_transaction_safe<int()>::value, ""); static_assert(!ct::is_transaction_safe<int(*)()>::value, ""); static_assert(!ct::is_transaction_safe<int(&)()>::value, ""); static_assert(!ct::is_transaction_safe<int(foo::*)() const>::value, ""); int main() {}