Template member function of a class template specialisation issue

The following bit of code from gmock (http://code.google.com/p/googlemock/) caused CC 5.9 ( and Studio Express) to emit:
"./include/gmock/gmock-printers.h", line 418: Error: static testing::internal::TuplePrefixPrinter<testing::internal::N>::PrintPrefixTo<testing::internal::TuplePrefixPrinter<testing::internal::N>::Tuple>(const testing::internal::TuplePrefixPrinter<testing::internal::N>::Tuple&, std::ostream *) already had a body defined.
Code:
template <size_t N>
struct TuplePrefixPrinter {
// Prints the first N fields of a tuple.
template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
*os << ", ";
UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
::Print(::std::tr1::get<N - 1>(t), os);
// Tersely prints the first N fields of a tuple to a string vector,
// one element for each field.
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
::std::stringstream ss;
UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
strings->push_back(ss.str());
template <>
template <typename Tuple>
void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
Print(::std::tr1::get<0>(t), os);
Removing the inline definition of TuplePrefixPrinter from the class and adding it after the specialisation fixed the issue.
Ian.

Hi, Ian. Please file a bug report at bugs.sun.com so we can track the problem.
- Steve

Similar Messages

  • Binding function pointer to class member fnction

    Hi,
    I have created a function pointer to class nonstatic member function. But facing some compilation issue. Can someone help on this.
    #include "stdafx.h"
    #include "iostream"
    #include <functional>
    using namespace std;
    using namespace std::placeholders;
    class A
    public:
    void Fun(void* param, bool b){cout<<"Hi\n";}
    typedef void (A::*fptr)(void*,bool);
    int _tmain(int argc, _TCHAR* argv[])
    fptr obj;
    auto f = std::bind(&A::Fun, &obj,_1,_2);
    f(NULL,1);
    return 0;

    See some samples about std::bind and std::function
    http://en.cppreference.com/w/cpp/utility/functional/bind
    http://en.cppreference.com/w/cpp/utility/functional/function
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Explicit template member function call from return value of function

    i couldn't see this in the list of C++ standards not implemented <http://developers.sun.com/tools/cc/documentation/ss9_docs/mr/READMEs/c++.html> but sun studio 9 doesn't seem to allow explicit calls to template member functions where the left-hand-side is the return value of a function. here's a test-case:
    template <typename T> class Ptr {
    public:
      T* p_;
      Ptr(T* p) : p_(p) { }
      template <typename U> Ptr(const Ptr<U>& u) : p_(u.p_) { }
      template <typename U> Ptr<U> cast() const { return Ptr<U>(*this); }
    class A {
    class B : public A {
    Ptr<A> test_cast_1(const Ptr<B>& b) { return b.cast<A>(); }
    Ptr<A> test_cast_2(const Ptr<B>& b) { return Ptr<B>(b).cast<A>(); }sun studio 9 CC complains with the following message:
    "sunstudio9-template-explicit-call.cc", line 18: Error: Unexpected type name "A" encountered.
    "sunstudio9-template-explicit-call.cc", line 18: Error: Operand expected instead of ")".
    2 Error(s) detected.
    (line 18 is test_cast_2)
    is this a known bug?
    cheers,
    /lib

    you omitted the required keyword template:
    template <typename T> class Ptr {
    public:
      T* p_;
      Ptr(T* p) : p_(p) { }
      template <typename U> Ptr(const Ptr<U>& u) : p_(u.p_) { }
      template <typename U> Ptr<U> cast() const { return Ptr<U>(*this); }
    class A {
    class B : public A {
    Ptr<A> test_cast_1(const Ptr<B>& b) { return b.cast<A>(); }
    Ptr<A> test_cast_2(const Ptr<B>& b) { return Ptr<B>(b).template cast<A>(); }

  • Pass C++ Class Member Function as a callable function in AIR Native Extension

    I'm writing an ANE and I'd like to know if anyone has been able to pass a C++ class member function pointer as a callable function from AIR? I have tried this so far with a little bit of C++11 trickery and it's crashing. I've also statically linked the libstdc++ into my library, according to the documentation, in order to ensure that these features I use work correctly. I have code like so:
    FakeWorld* world = new FakeWorld();
    *numFunctions = 1;
    memberFunctions = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * (*numFunctions));
    ANEMemberFunction mCreateFakeBody = std::tr1::bind(&FakeWorld::createFakeBody, world, std::tr1::placeholders::_1, std::tr1::placeholders::_2, std::tr1::placeholders::_3, std::tr1::placeholders::_4);
    ANEFunction* createFakeBody = mCreateFakeBody.target<ANEFunction>();
    memberFunctions[0].name = (const uint8_t*) "createFakeBody";
    memberFunctions[0].functionData = NULL;
    memberFunctions[0].function = createFakeBody;
    FRESetContextNativeData(ctx, (void*)world);
    I just realized I'm using C here for allocating the member functions array.. silly me, but I don't think this is the cause of my issue. I refuse to believe that Adobe has built to the Native Extensions portion of the runtime in such a way that I have to cram every single function I want to create (natively) into a global, C formatted namespace (Especially since the documentation says that C is only required for the extenion and context initializing function interfacing and the rest of the code can be done in C++ or objective-C). So please let me know if and how this is possible and I thank you so much in advance for your time!P.
    P.S. Currently when I run this code, I can do the object initialization just fine. As soon as I invoke the "createFakeBody" method on the native side, the runtime dies and simply says:
    Problem signature:
      Problem Event Name: BEX
      Application Name: adl.exe
      Application Version: 3.1.0.4880
      Application Timestamp: 4eb7612e
      Fault Module Name: StackHash_0a9e
      Fault Module Version: 0.0.0.0
      Fault Module Timestamp: 00000000
      Exception Offset: 00000000
      Exception Code: c0000005
      Exception Data: 00000008
      OS Version: 6.1.7601.2.1.0.256.48
      Locale ID: 1033
      Additional Information 1: 0a9e
      Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
      Additional Information 3: 0a9e
      Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
    Read our privacy statement online:
      http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
    If the online privacy statement is not available, please read our privacy statement offline:
      C:\Windows\system32\en-US\erofflps.txt
    Thanks again for your assitance.

    It's been a little while since i've dealt with C++ and not up to speed on tr1 or C++0x, so forgive me if i'm not helping.
    The the examples of std::tr1::bind that i'm seeing out there seem to be either dereferencing the bound 'this' pointer when creating the bound method, i.e. in your case *world instead of world, or using std::tr1::ref(*world), therefore i believe that bind expects the bound parameters to be passed by reference.
    Given that the result of std::tr1::bind is callable (basing that on http://stackoverflow.com/questions/3678884/virtual-member-functions-and-stdtr1function-how -does-this-work) could you simplify to the following:
    memberFunctions[0].name = (const uint8_t*) "createFakeBody";
    memberFunctions[0].functionData = NULL;
    memberFunctions[0].function = std::tr1::bind(&FakeWorld::createFakeBody, *world, std::tr1::placeholders::_1, std::tr1::placeholders::_2, std::tr1::placeholders::_3, std::tr1::placeholders::_4);
    Or for an even simpler starting point, creating a test member function 'helloWorld' in FakeWorld that takes no arguments and using:
    memberFunctions[0].name = (const uint8_t*) "helloWorld";
    memberFunctions[0].functionData = NULL;
    memberFunctions[0].function = std::tr1::bind(&FakeWorld::helloWorld, *world);
    Hope this helps.

  • Reference to Class Member Functions

    Hello all.
    I have a question about references to LV class member functions. I have a small example to demonstrate my problem.
    My test class Base implements a reentrant public dynamic dispatch member function, doSomething.vi. 
    Another test class, Child, inherits Base and overrides the implementation of doSomething.vi.
    Now say I have an array of Base objects (which could include any objects from classes that inherit Base). I want to run the doSomething methods for all the objects in the array in parallel.
    In C++, I'd define a pointer to the virtual member function doSomething, and use it with each object in the array and the correct version of doSomething would be called.
    In Labview, the only way I've found to do it is like this:
    This is less than ideal, because it relies on every child class implementing doSomething, and relies on specific names for the inputs to the method. 
    Is there a better way to do this?
    Thank you,
    Zola

    I still suspect you are over-working this code and not leting LVOOP do tis thing.
    As I understand it you want to creae an active object but detemine its class at run time. The recent Architect summit touched on messaging for what they are calling a "worker Pool" pattern or what-not. YOu may want to search on the summit stuff. lacking that I'll share some images of where I did something similar ( I think). Note this is an older app and new stuff like the "Start Asyncronous call..." has been introduced making this even easier.
    I want to create a new Active Object (thread running in the background) so I invoke a method to do so
    It invokes the following that create some queues for talking to it and getting info back.
    Time does not permit me doing a complete write-up but I have assembled the above images into a LVOOP Albumn found here.
    When you click on one of those images you will get a large view as shown in this example.
    Just below that image you will find a link to the original thread where I posted the image and talked about it.
    I believe the best I can do for you at the moment is to urge you to browse my albumn and chase the links.
    That agllery was assembled in an attmept to help you and other before you asked. I hope it is helpful.
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Making all named member functions of an actionscript class avlbl to ExternalInterface automatically

    Making all named member functions of an actionscript class available to ExternalInterface automatically :
    I am trying to custom-tweak the as3 compiler to generate instructions to register all functions in the ClassDefinitionNode to ExternalInterface.
    I guess the operation will have to be performed somwhere between the analyze sequences of the compiler, but am not quite able locate where.
    I have this codelet (executed for all constructors, for every non-constructor)
                    ArgumentListNode argListNode = new ArgumentListNode(
                            new LiteralStringNode(
                                    NodeMagic.getClassName(clNode)+ "." + functionCommonNode.identifier.name), 0);
                    //argListNode.items.add(new LiteralNullNode());
                    argListNode.items.add(new IdentifierNode(functionCommonNode.identifier.name, 0));
                    MemberExpressionNode mnode = new MemberExpressionNode(new IdentifierNode("ExternalInterface", 0),
                            new InvokeNode("addCallback",
                                    argListNode),0);
                    mnode.ref = new ReferenceValue(cx, null, "ExternalInterface", ObjectValue.intrinsicNamespace); //NOT TOO SURE ABOUT THIS ONE
                    constructor.body.items.add(mnode
    Any assistance would be appreciated!
    Thanks!

    Making all named member functions of an actionscript class available to ExternalInterface automatically :
    I am trying to custom-tweak the as3 compiler to generate instructions to register all functions in the ClassDefinitionNode to ExternalInterface.
    I guess the operation will have to be performed somwhere between the analyze sequences of the compiler, but am not quite able locate where.
    I have this codelet (executed for all constructors, for every non-constructor)
                    ArgumentListNode argListNode = new ArgumentListNode(
                            new LiteralStringNode(
                                    NodeMagic.getClassName(clNode)+ "." + functionCommonNode.identifier.name), 0);
                    //argListNode.items.add(new LiteralNullNode());
                    argListNode.items.add(new IdentifierNode(functionCommonNode.identifier.name, 0));
                    MemberExpressionNode mnode = new MemberExpressionNode(new IdentifierNode("ExternalInterface", 0),
                            new InvokeNode("addCallback",
                                    argListNode),0);
                    mnode.ref = new ReferenceValue(cx, null, "ExternalInterface", ObjectValue.intrinsicNamespace); //NOT TOO SURE ABOUT THIS ONE
                    constructor.body.items.add(mnode
    Any assistance would be appreciated!
    Thanks!

  • How to access function from Top Class to Function of class that contain the the member variable of TopClass

    Dear All,
    is there any way that i can access function or member variable of aggregate class.
    i am working in Visual Studio 2010 
    and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
    previously all in exe and i am working this like
    CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
    somevar = pDoc->xDoc.mVar.GetValue (); 
    now i am trying to put all in dll. so getting problem 
    will i get help on this. thanks in advance.
    below code is just an example.
    for example
    // dll 1
    class aaa : public BaseClass
    public:
    int Index;
    char *cName;
    void doSometing()
    if (GetCurBColor() == 125) // how to access GetCurBColor function of the
    color = GetCurBColor();
    long color;
    // dll 2
    class bbb :public BaseClass
    public:
    int Index;
    long lSize;
    long color;
    void doSometing();
    // dll 3
    class DDD
    public:
    vector <aaa> va;
    vector <bbb> vb;
    int cura;
    int curb;
    long GetCurBColor ()
    return vb[curb].color;
    };// MFC doc/view support
    /// in exe in document
    class inExe
    public:
    DDD d;
    void addB()
    { bbb bb;
    bb.color = 152;
    d.vb.push_back(bb);
    bb.color = 122;
    d.vb.push_back(bb);
    bb.color = 1232;
    d.vb.push_back(bb);
    d.curb = 1;
    void addA()
    { aaa aa;
    aa.color = 152;
    d.va.push_back(aa);
    aa.color = 1232;
    d.va.push_back(aa);
    aa.color = 1542;
    d.va.push_back(aa);
    aa.color = 15;
    d.va.push_back(aa);
    d.cura = 2;
    d.va [1].doSometing ();

    Dear All,
    is there any way that i can access function or member variable of aggregate class.
    i am working in Visual Studio 2010
    and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
    previously all in exe and i am working this like
    CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
    somevar = pDoc->xDoc.mVar.GetValue ();
    now i am trying to put all in dll. so getting problem
    What problem?
    The rules of C++ do not change because some of the code ins in a DLL. But the classes in a DLL need to be exported. See for example
    https://msdn.microsoft.com/en-us/library/81h27t8c.aspx
    You should also supply a macro so that the class header can be used in both the DLL and the client. See for example
    http://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch
    If  you exchange memory between the DLL and the client (as your example will do, because of the std::vector content), you should also be sure to use the same version of the compiler for each module, and to dynamically link to the CRT.
    I would also advise you to start with a less complicated scenario, with just one DLL.
    David Wilkinson | Visual C++ MVP

  • How can I use a generic indifferently in one of the generic's member functions?

    I'm curious about the following situation:
    I'd like to access another generic's private member in a constructor. How can I do that irrespective of the generic's actual type?
    Here's a sample of what I'm trying to accomplish:
    public class C<T>
    private int _hdc;
    // private T _someMember;
    public C()
    this._hdc = CreateHdc();
    public C(C src) // what would be the correct signature here to be able to run the assignment in ::f() below?
    this._hdc = src.hdc;
    function f()
    C<int> a = new C();
    C<string> b = new C(a); // how can I get this to work?
    Do I need to create a non-generic base class to be able to use a differently typed object in the construtor? Or is there some C# construct that will allow me to define an untyped generic parameter and only use the untyped members from that parameter?
    Still people out there alive using the keyboard?
    Working with SQL Server/Office/Windows and their poor keyboard support they seem extinct...

    >>I'd like to access another generic's private member in a constructor.
    You cannot access a class' private member from any other class directly. You could expose a private field through a property or define a public method (or constructor) that sets the private field though.
    >>How can I do that irrespective of the generic's actual type?
    You cannot assign a string field to an int value or the other way around without converting the value to a string/int first.
    A C<int> object always has an int field - the generic class is not really a type of its own but rather a "blue-print" or a template for a type - and you cannot assign this one to a string value.
    Since the C<string> class Always has a string field you need to convert the int value of the C<int> object to a string before you can ever assign the string field to this value:
    C<int> a = new C();
    C<string> b = new C(a.ToString());
    C<int> and C<string> are two completely different types. They are not related to each other and as mentioned you cannot assing a string field to an int value.
    >>Or is there some C# construct that will allow me to define an untyped generic parameter and only use the untyped members from that parameter?
    There is no such thing as "an unyped generic parameter" in C#. T always refers to a type and you must specify the type when you create an instance of the generic type.
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question.

  • Not able to access the result set from one member function to another

    Im new to jdbc
    I have declared a connection object , a result set object and statement object in one member function and i am not able to access these in another member function. But both are in the same class
    Kindly help
    Thanks
    Shasi

    Kindly refrain from double-posting:
    http://forum.java.sun.com/thread.jspa?threadID=700659&tstart=0
    - Saish

  • How to load function from derived class from dll

    Dear all,
    how to access extra function from derived class.
    for Example
    //==========================MyIShape.h
    class CMyIShape
    public:
    CMyIShape(){};
    virtual ~CMyIShape(){};
    virtual void Fn_DrawMe(){};
    // =========== this is ShapRectangle.dll
    //==========================ShapRectangle .h
    #include "MyIShape.h"
    class DLL_API ShapRectangle :public CMyIShape
    public:
    ShapRectangle(){};
    virtual ~ShapRectangle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_ChangeMe(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapRectangle();
    // return the created function
    return m_Obj;
    // =========== this is ShapCircle .dll
    //==========================ShapCircle .h
    #include "MyIShape.h"
    class DLL_API ShapCircle :public CMyIShape
    public:
    ShapCircle(){};
    virtual ~ShapCircle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_GetRadious(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapCircle();
    // return the created function
    return m_Obj;
    in exe there is no include header of of ShapCircle and ShapRectangle 
    and from the exe i use LoadLibrary and GetProcAddress .
    typedef CMyIShape* (*CREATE_OBJECT) ();
    CMyIShape*xCls ;
    //===================== from ShapeCircle.Dll
    pReg=  (CREATE_OBJECT)GetProcAddress (hInst ,"CreateShape");
    xCls = pReg();
    now xCls give all access of base class. but how to get pointer of funciton Fn_GetRadious() or how to get access.
    thanks in advance.

    could you please tell me in detail. why so. or any reference for it. i love to read.
    i don't know this is bad way.. but how? i would like to know.
    I indicated in the second sentence. Classes can be implemented differently by different compilers. For example, the alignment of member variables may differ. Also there is the pitfall that a class may be allocated within the DLL but deallocated in the client
    code. But the allocation/deallocation algorithms may differ across different compilers, and certainly between DEBUG and RELEASE mode. This means that you must ensure that if the DLL is compiled in Visual Studio 2010 / Debug mode, that the client code is also
    compiled in Visual Studio 2010 / Debug mode. Otherwise your program will be subject to mysterious crashes.
    is there any other way to archive same goal?
    Of course. DLL functionality should be exposed as a set of functions that accept and return POD data types. "POD" means "plain-ole-data" such as long, wchar_t*, bool, etc. Don't pass pointers to classes. 
    Obviously classes can be implemented within the DLL but they should be kept completely contained within the DLL. You might, for example, expose a function to allocate a class internally to the DLL and another function that can be called by the client code
    to free the class. And of course you can define other functions that can be used by the client code to indirectly call the class's methods.
    and why i need to give header file of ShapCircle and shapRectangle class, even i am not using in exe too. i though it is enough to give only MyIShape.h so with this any one can make new object.
    Indeed you don't have to, if you only want to call the public properties and methods that are defined within MyIShape.h.

  • Member function and member procedure inside an object type in Oracle.

    Hi All,
    Please do have a look at these codes and help me understand. I have no idea about this member function and member procedure. How do they work? Please explain me about this.
    Regards,
    BS2012
    create type foo_type as object (
      foo number,
      member procedure proc(p in number),
      member function  func(p in number) return number
    create type body foo_type as
      member procedure proc(p in number) is begin
        foo := p*2;
      end proc;
      member function func(p in number) return number is begin
        return foo/p;
      end func;
    end;
    /

    Methods are just like functions or procedures in a package, except they're not in a package, their part of an object type.
    The object has attributes (which are the variables declared in it).
    To use such an object you would do things like this...
    SQL> set serverout on
    SQL>
    SQL> declare
      2    v_foo foo_type;
      3    v_val number;
      4  begin
      5    v_foo := foo_type(20); -- instantiate the object and initialize the object attributes
      6    v_foo.proc(20); -- call the object method (proc)
      7    v_val := v_foo.func(4); -- call the object method (func)
      8    dbms_output.put_line(v_val);
      9  end;
    10  /
    10
    PL/SQL procedure successfully completed.The Type definition you've declared creates the object class, but not actually an object itself.
    To actually have an object you need to declare a variable of that object class type, and then instantiate it. When you instantiate the object you need to initialize all the attributes (generally you can pass null if required for each of them to initialize them).
    Once you have your object instantiated, you can call the methods within that object as demonstrated above, a bit like calling functions and procedures in a package, except they are methods within the object type itself, and therefore called directly by referencing them from the variable.
    The documentation goes into a lot more detail of objects if you look it up.

  • Cannot call member function on object type

    On 8.1.6 I cannot call a member function from SQL in the way described in the manual.
    The following example is almost copied from the manual:
    create or replace TYPE foo AS OBJECT (a1 NUMBER,
    MEMBER FUNCTION getbar RETURN NUMBER);
    create or replace type body foo is
    MEMBER FUNCTION getbar RETURN NUMBER is
    begin
    return 45;
    end;
    end;
    CREATE TABLE footab(col foo);
    SELECT col,foo.getbar(col) FROM footab; -- OK
    select col,col.getbar() from footab; -- ERROR
    The second select is the way it should be, but I get an error "invalid column name".
    Using the first select, I get the result. This is strange because this is more or less the 'static member' notation (filling in the implicit self parameter myself).
    Is this a known bug in 8.1.6, maybe fixed in later versions?

    Konstantin,
    Did you use loadjava to load the compiled class into the Oracle Database?
    Regards,
    Geoff
    Hello!
    I need to write a member function for object type with java.
    for example:
    create type test as object(
    id number,
    name varchar2(20),
    member function hallo return number);
    create type body test as
    member function hallo return number
    as language java
    name 'test.hallo() return int;
    create table test of test;
    My java-file is:
    public class test {
    public int hallo() {
    return 5;
    select t.hallo() from test t;
    It's does not run. Why?
    I get always an error back. Wrong types or numbers of parameters!!
    please help me.
    thanks in advance
    Konstantin

  • This code executes normally in VS2014, despite the fact that an inline member function is not defined in every TU in which it is odr-used.

    Consider this code:
    header.h:
    #include <iostream>
    class A{
    int i;
    public:
    A() : i(101) {}
    void print();
    void g(A&);
    cpp1:
    #include "header.h"
    inline void A::print() { std::cout << i << '\n'; }
    int main()
    A a;
    a.print();
    g(a);
    cpp2:
    #include "header.h"
    void g(A& a) { a.print(); }
    Note that the member function A::print is defined outside its class with the specifier inline. The code executes normally in VS2014, despite the fact that the member function is odr-used in cpp2, but it is not defined in this file.
    I found the following quotes from the C++11 Standard:
    9.3/3:
    An inline member function (whether static or non-static) may also be defined outside of its class definition provided either its declaration in the class definition or its definition outside of the class definition declares the function as inline.
    3.2/3:
    An inline function shall be defined in every translation unit in which it is odr-used.
    7.1.2/4:
    An inline function shall be defined in every translation unit in which it is odr-used and shall have exactly the same definition in every case.
    The two last quotes above don't speak exactly about a member function but I believe they should be applied in this case too, as the inline specifier is a hint for the compiler to expand the function inline at the point of call. If we assume the compiler
    does this inline expansion, how does it know the definition of the member function, while compiling the cpp2 file?  

    On 12/31/2014 12:13 PM, Belloc wrote:
    C++ is supported on many different systems, with tools provided by many different vendors. Microsoft's linker happens to be pretty smart about merging identical blocks of code. Other toolchains may use linkers that weren't designed with this in mind,
    and that would choke on multiple definitions of the same symbol. The C++ standard is written so that it's actually implementable, on as many platforms as possible.
    Frankly I don't understand your statement above. What would be the difficulty for any compiler*that is already compliant with 3.2/3 and 7.1.2/4*, to adapt its code, so that each call to an inline function in a TU, which doesn't carry the function
    definition, is simply not inlined?
    That's the easy part. The "there's identical function definition in every .obj file, and the linker is expected to merge them all together" is the hard part. Normally, if you define a regular (non-inline) function in more than one source
    file, you get a linker error. Microsoft's linker has a special way to mark "defined more than once, just pick any copy" block of code (see __declspec(selectany) ). Other linkers may not.
    Igor Tandetnik

  • Input solicited: List function support as member functions in CFML

    G'day:
    I'm concerned about how Adobe have implemented the list-oriented member functions in ColdFusion 11. And I was hopeing to capture some community input as to what other people think, before raising it with Adobe:
    Survey: lists in CFML, and the naming of list member functions
    It'd be cool if you could take the time to complete the survey.
    Thanks.
    Adam

    ruerric wrote:
    I created a custom class called Rooms with all the appropriate setters and getters.Arguably, getters and setters are seldom appropriate.
    I iterated through a csv file and input all of the data into my custom object class and then put that object into a list by using list.add().
    Now I want to access the class methods through the use of the list.. how can I do so?
    How I declared my list:
    List list = new ArrayList<Rooms>(); // List implemented as growable array
    Rooms xxx = (Rooms).list.get(20);
    Says illegal start of type error.. What are you actually trying to accomplish here? Is list a static field of Rooms?
    Also, I want to sort the list by the room capacity. My Rooms class has a .setCap and .getCap function but how can I sort the list using that?
    From what I know about list.. it has a sort method but not exactly the way I want to sort a custom made class object..List doesn't have a sort method. There's a method in java.util.Collections to sort a list. I think it's "sort". You can pass it a java.util.Comparator that you write, to sort by whatever criteria you like.
    Question: will the capacity of a room ever change? In real life, if you build a hotel, and a room has a capacity of 3 persons, does the room ever change capacity? If the capacity never changes, then it's debatable whether you really need a setCap() method. It would be better to set the capacity once, in the constructor, and leave it.

  • [SOLVED] Passing a non-static member function as a function pointer

    I need to pass a function pointer to a public method to a system call, nftw() to be precise.
    I know that member functions don't match the required signature because of the hidden 'this' pointer, but
    the only way to work around that is by using a small wrapper function that makes use of a global variable (the object of which I want to call the method).
    Speaking in code, this is the way I've solved the problem currently:
    // create a global variable here
    static MyObject obj;
    static int myObject_method_wrapper(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf) {
    return obj.handleDirEntry(fpath, sb, tflag, ftwbuf);
    // somewhere in main()
    nftw(walkroot, myObject_method_wrapper, 20, FTW_PHYS);
    Now, my question: Can't this be done without a global instance of MyObject? It is pointed out here that other ways are existent, but sadly they are not mentioned.
    Glad if someone could help me out!
    Last edited by n0stradamus (2012-04-24 22:59:47)

    I think you are stuck:
    1. You are not in control of the interface (of nftw), and furthermore,
    2. You are not in control of any of the parameters sent to the callback.
    nftw has no idea which one of your objects it is supposed to reference, and
    there's no apparent way to tell it.
    But given this situation, are you sure it makes sense to use a non-static
    member?  It seems kind of strange to me-- any instance-specific data is
    necessarily going to be independent of the function calls!  So even if you
    engineer something to avoid using a global, whatever you engineer is still
    going to involve some *arbitrary* instance of your class (e.g. peterb's
    solution, which uses the most recently created instance).  The arbitrary-ness
    doesn't feel right, since it sort of implicitly says that none of the instance
    data is important.  No important instance-specific data sounds like static...

Maybe you are looking for

  • Hyperlink in application

    hi,i want to add hyperlink in java application mean when user click the hyperlink it goes to website.thanks

  • Upgrade the IPCC xpress and IP IVR to 7.0.1.

    HI, We are upgrading Our existing IPT & IPCC clusters. Last weekend we have upgarde the CUCM from 5.1 to 7.1.6 sucessfully. This weekend we are planning to upgrade the IPCC xpress and IP IVR to 7.0.1. I would like to know Upgrade path, strategy, Plan

  • How to submit an app to multiple categories?

    Hi Everyone, I have an app that should be in both education and reference categories. Can someone please explain how to get it into more than one category? It is already accepted into the education category. How do I submit for the reference category

  • DPI and image size

    hello, I have a doubt. when I make an image to be included in a iPhone4,for example with Photoshop, I must do 320dpi, or 72, but bigger thanan iphone 3g?

  • RMAN back up Restore

    Hi Gurus, I want to restore back up of PRD server in my QAS server by rman, please suggest what are all the steps required for this as i never restored a back up by rman. Thanks & Regards Chetan Anguralia