mirror of
https://github.com/boostorg/callable_traits.git
synced 2026-02-13 12:22:18 +00:00
calling convention examples
This commit is contained in:
37
example/changing_calling_conventions.cpp
Normal file
37
example/changing_calling_conventions.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*!<-
|
||||
Copyright (c) 2016 Barrett Adair
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
->*/
|
||||
|
||||
//[ changing_calling_conventions
|
||||
#define CALLABLE_TRAITS_ENABLE_STDCALL
|
||||
#define CALLABLE_TRAITS_ENABLE_FASTCALL
|
||||
|
||||
#include <type_traits>
|
||||
#include <callable_traits/has_calling_convention.hpp>
|
||||
#include <callable_traits/add_calling_convention.hpp>
|
||||
#include <callable_traits/remove_calling_convention.hpp>
|
||||
|
||||
namespace ct = callable_traits;
|
||||
|
||||
int main() {
|
||||
|
||||
using f = void(__fastcall *)(int);
|
||||
|
||||
static_assert(ct::has_calling_convention<f, ct::fastcall_tag>(), "");
|
||||
static_assert(!ct::has_calling_convention<f, ct::stdcall_tag>(), "");
|
||||
|
||||
using expect = void(__stdcall *)(int);
|
||||
|
||||
static_assert(ct::has_calling_convention<expect, ct::stdcall_tag>(), "");
|
||||
static_assert(!ct::has_calling_convention<expect, ct::fastcall_tag>(), "");
|
||||
|
||||
using g = ct::remove_calling_convention<f>;
|
||||
using test = ct::add_calling_convention<g, ct::stdcall_tag>;
|
||||
|
||||
static_assert(ct::has_calling_convention<test, ct::stdcall_tag>(), "");
|
||||
static_assert(std::is_same<test, expect>::value, "");
|
||||
}
|
||||
//]
|
||||
Reference in New Issue
Block a user