function-signature

Is it possible to retrieve the argument types from a (Functor member's) function signature for use in a template?

老子叫甜甜 提交于 2019-12-04 09:20:35
Assume you have a functor: struct MyFunctor { bool operator ()( int value ) { return true; } }; Is it possible to retrieve a functor's member's argument type for use within your template? The following is a use of this mythical functionality: template < typename FunctorType > bool doIt( FunctorType functor, typename FunctorType::operator()::arg1 arg ) { return functor( arg ); } Is there a valid syntax that would substitute for my mythical FunctorType::operator()::arg1 ? No there is not. The most elegant way to do this would be to either require your functors to provide a typedef for the

Can an unnamed parameter of function have a default value?

眉间皱痕 提交于 2019-12-04 01:33:04
Is the following code legal in C++? void f(void* = 0) {} int main() { f(); } Which page of the C++ standard states that this usage is legal? Yes, it's legal. There is no standard wording to allow this combination of features specifically; there simply isn't any to disallow it, either. Default argument syntax applies to function parameters in a parameter-declaration : [C++11: 8.3.6/1]: If an initializer-clause is specified in a parameter-declaration this initializer-clause is used as a default argument. Default arguments will be used in calls where trailing arguments are missing. ...and

Function pointers with default parameters in C++

二次信任 提交于 2019-11-30 16:49:03
How does C++ handle function pointers in relation to functions with defaulted parameters? If I have: void foo(int i, float f = 0.0f); void bar(int i, float f); void (*func_ptr1)(int); void (*func_ptr2)(int, float); void (*func_ptr3)(int, float = 10.0f); Which function pointers can I use in relation to which function? Both foo() and bar() can only be assigned to func_ptr2 . §8.3.6/2 : A default argument is not part of the type of a function. [Example: int f(int = 0); void h() { int j = f(1); int k = f(); // OK, means f(0) } int (*p1)(int) = &f; int (*p2)() = &f; // error: type mismatch --end

Is there a tool that generates P/Invoke signatures for arbitrary unmanaged DLL?

你。 提交于 2019-11-28 17:00:25
I stumbled upon a tool that generates P/Invoke signatures for Microsoft's own unmanaged DLLs: PInvoke Interop Assistant Is there a similar tool that will generate P/Invoke signatures for third-party unmanaged DLLs? Alternately, any way to feed a third-party DLL to PInvoke Interop Assistant EDIT: Actual issue I am trying to resolve Google quickly found http://www.pinvoker.com/ (Compatiblity listed as VS2005, 2008, and 2010; it doesn't seem to have been updated to work with newer versions) Microsoft's C++/CLI compiler can also do this, if you use /clr:safe and #include the header file, it will

Is there a tool that generates P/Invoke signatures for arbitrary unmanaged DLL?

99封情书 提交于 2019-11-27 09:59:59
问题 I stumbled upon a tool that generates P/Invoke signatures for Microsoft's own unmanaged DLLs: PInvoke Interop Assistant Is there a similar tool that will generate P/Invoke signatures for third-party unmanaged DLLs? Alternately, any way to feed a third-party DLL to PInvoke Interop Assistant EDIT: Actual issue I am trying to resolve 回答1: Google quickly found http://www.pinvoker.com/ (Compatiblity listed as VS2005, 2008, and 2010; it doesn't seem to have been updated to work with newer versions)

How to define template function within template class in *.inl file

守給你的承諾、 提交于 2019-11-26 20:14:06
问题 I write template declaration in *.hpp file and their "definition" in *.inl file linked from *.hpp just like this: //*.hpp template <typename T1, typename T2> class SomeClass { public: void someMethod(); }; //*.inl template <typename T1, typename T2> void SomeClass<T1, T2>::someMethod() { } but how to write extra templated method inside template class in *.inl file? //*.hpp template <typename T1, typename T2> class SomeClass { public: void someMethod(); template <typename E> void