Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Other Features

add_transaction_safe
remove_transaction_safe
is_transaction_safe
add_noexcept
remove_noexcept
is_noexcept
Header
#include <boost/callable_traits/add_transaction_safe.hpp>
Definition
template<typename T>
using add_transaction_safe_t = //see below

template<typename T>
struct add_transaction_safe {
    using type = add_transaction_safe_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Adds the transaction_safe specifier to T, if not already present.
Compatibility Notes

A static_assert always fails when instantiating 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.

Input/Output Examples

T

add_transaction_safe_t<T>

int()

int() transaction_safe

int (&)()

int(&)() transaction_safe

int (*)()

int(*)() transaction_safe

int(foo::*)()

int(foo::*)() transaction_safe

int(foo::*)() &

int(foo::*)() & transaction_safe

int(foo::*)() &&

int(foo::*)() && transaction_safe

int(foo::*)() const

int(foo::*)() const transaction_safe

int(foo::*)() transaction_safe

int(foo::*)() transaction_safe

int

(substitution failure)

int foo::*

(substitution failure)

int (*&)()

(substitution failure)

Example Program
#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() {}
Header
#include <boost/callable_traits/remove_transaction_safe.hpp>
Definition
template<typename T>
using remove_transaction_safe_t = //see below

template<typename T>
struct remove_transaction_safe {
    using type = remove_transaction_safe_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Removes the member transaction_safe specifier from T, if present.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

remove_transaction_safe_t<T>

int() const transaction_safe

int() const

int(*)() transaction_safe

int(*)()

int(&)() transaction_safe

int(&)()

int(foo::*)() transaction_safe

int(foo::*)()

int() const

int() const

int(*)()

int(*)()

int(&)()

int(&)()

int

(substitution failure)

int foo::*

(substitution failure)

int (foo::* const)()

(substitution failure)

Example Program
#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() {}
Header
#include <boost/callable_traits/is_transaction_safe.hpp>
Definition
template<typename T>
struct is_transaction_safe; //see below


#ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES

template<typename T>
struct is_transaction_safe_v {
    static_assert(std::is_same<T, detail::dummy>::value,
        "Variable templates not supported on this compiler.");
};

#else

template<typename T>
constexpr bool is_transaction_safe_v = //see below
#endif
Constraints
  • none
  • Behavior
  • 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
  • On compilers that support variable templates, is_transaction_safe_v<T> is equivalent to is_transaction_safe<T>::value.
Compatibility Notes

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.

Input/Output Examples

T

is_transaction_safe_v<T>

int() const transaction_safe

true

int(*)() transaction_safe

true

int(&)() transaction_safe

true

int(foo::*)() transaction_safe

true

int() const

false

int() volatile

false

int(foo::*)() const

false

int() const

false

int() volatile

false

int() &

false

int(*)()

false

int

false

int foo::*

false

const int foo::*

false

Example Program
#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() {}
Header
#include <boost/callable_traits/add_noexcept.hpp>
Definition
template<typename T>
using add_noexcept_t = //see below

template<typename T>
struct add_noexcept {
    using type = add_noexcept_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Adds a noexcept specifier to T, if not already present.
Compatibility Notes

A static_assert always fails when instantiating this template if your compiler doesn't support noexcept on types (a C++17 feature). At the time of this writing, GCC 7.0.0+ and Clang 4.0+ are the only compiler that can use feature.

Input/Output Examples

T

add_noexcept_t<T>

int()

int() noexcept

int (&)()

int(&)() noexcept

int (*)()

int(*)() noexcept

int(foo::*)()

int(foo::*)() noexcept

int(foo::*)() &

int(foo::*)() & noexcept

int(foo::*)() &&

int(foo::*)() && noexcept

int(foo::*)() const transaction_safe

int(foo::*)() const transaction_safe noexcept

int(foo::*)() noexcept

int(foo::*)() noexcept

int

(substitution failure)

int foo::*

(substitution failure)

int (*&)()

(substitution failure)

Example Program
#include <type_traits>
#include <boost/callable_traits/add_noexcept.hpp>

using boost::callable_traits::add_noexcept_t;

static_assert(std::is_same<
	add_noexcept_t<int()>,
	int() noexcept
>{}, "");

int main() {}
Header
#include <boost/callable_traits/remove_noexcept.hpp>
Definition
template<typename T>
using remove_noexcept_t = //see below

template<typename T>
struct remove_noexcept {
    using type = remove_noexcept_t<T>;
};
Constraints
  • T must be one of the following:
    • function type
    • function pointer type
    • function reference type
    • member function pointer type
Behavior
  • A substitution failure occurs if the constraints are violated.
  • Removes the noexcept specifier from T, if present.
Compatibility Notes

Full support on GCC 4.7.4+, Clang 3.5+, Visual Studio 2015, and XCode 6.4+.

Input/Output Examples

T

remove_noexcept_t<T>

int() const noexcept

int() const

int(*)() noexcept

int(*)()

int(&)() noexcept

int(&)()

int(foo::*)() noexcept

int(foo::*)()

int() const

int() const

int(*)()

int(*)()

int(&)()

int(&)()

int

(substitution failure)

int foo::*

(substitution failure)

int (foo::* const)()

(substitution failure)

Example Program
#include <type_traits>
#include <boost/callable_traits/remove_noexcept.hpp>

using boost::callable_traits::remove_noexcept_t;

static_assert(std::is_same<
	remove_noexcept_t<int() noexcept>,
	int()
>{}, "");

int main() {}
Header
#include <boost/callable_traits/is_noexcept.hpp>
Definition
template<typename T>
struct is_noexcept; //see below


#ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES

template<typename T>
struct is_noexcept_v {
    static_assert(std::is_same<T, detail::dummy>::value,
        "Variable templates not supported on this compiler.");
};

#else

template<typename T>
constexpr bool is_noexcept_v = //see below
#endif
Constraints
  • none
  • Behavior
  • std::false_type is inherited by is_noexcept<T> and is aliased by typename is_noexcept<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 noexcept specifier
    • T is a function object with a non-overloaded operator(), where the operator() has a noexcept specifier
  • On compilers that support variable templates, is_noexcept_v<T> is equivalent to is_noexcept<T>::value.
Compatibility Notes

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 noexcept at all.

Input/Output Examples

T

is_noexcept_v<T>

int() const noexcept

true

int(*)() noexcept

true

int(&)() noexcept

true

int(foo::*)() noexcept

true

int() const

false

int() volatile

false

int(foo::*)() const

false

int() const

false

int() volatile

false

int() &

false

int(*)()

false

int

false

int foo::*

false

const int foo::*

false

Example Program
#include <boost/callable_traits/is_noexcept.hpp>

namespace ct = boost::callable_traits;

struct foo;

static_assert(ct::is_noexcept<int() noexcept>::value, "");
static_assert(ct::is_noexcept<int(*)() noexcept>::value, "");
static_assert(ct::is_noexcept<int(&)() noexcept>::value, "");
static_assert(ct::is_noexcept<int(foo::*)() const noexcept>::value, "");

static_assert(!ct::is_noexcept<int()>::value, "");
static_assert(!ct::is_noexcept<int(*)()>::value, "");
static_assert(!ct::is_noexcept<int(&)()>::value, "");
static_assert(!ct::is_noexcept<int(foo::*)() const>::value, "");

int main() {}

PrevUpHomeNext