Topic: Proposal: implicit converstion of member function


Author: wm2015email@gmail.com
Date: Sat, 19 Nov 2016 07:43:58 -0800 (PST)
Raw View
------=_Part_6602_1406022528.1479570238330
Content-Type: multipart/alternative;
 boundary="----=_Part_6603_1386016320.1479570238330"

------=_Part_6603_1386016320.1479570238330
Content-Type: text/plain; charset=UTF-8

Here's some half finished code of how I was trying to solve a similar
problem... using templates...
I was wondering why they don't just build this type of stuff into the C++
compiler?  I don't really
want to even mess around with converting static method into non-static
methods...
its just make inter-object communication messy if they don't fix that
problem...

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fe348f09-56d1-4f4d-babe-55e4e0fa41a9%40isocpp.org.

------=_Part_6603_1386016320.1479570238330
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Here&#39;s some half finished code of how I was trying to =
solve a similar problem... using templates...<br>I was wondering why they d=
on&#39;t just build this type of stuff into the C++ compiler?=C2=A0 I don&#=
39;t really<br>want to even mess around with converting static method into =
non-static methods...<br>its just make inter-object communication messy if =
they don&#39;t fix that problem...<br><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/fe348f09-56d1-4f4d-babe-55e4e0fa41a9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fe348f09-56d1-4f4d-babe-55e4e0fa41a9=
%40isocpp.org</a>.<br />

------=_Part_6603_1386016320.1479570238330--

------=_Part_6602_1406022528.1479570238330
Content-Type: text/x-chdr; charset=US-ASCII; name=fl_callback.h
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=fl_callback.h
X-Attachment-Id: 8f2c829d-3cb7-45d7-a4ac-22d2d34bfcf0
Content-ID: <8f2c829d-3cb7-45d7-a4ac-22d2d34bfcf0>

#ifndef EXT_FL_CALLBACK_H
#define EXT_FL_CALLBACK_H

// Disclaimers: This is just some quick code that I put together to experiment with FLTK
//   library and that seems to work well for what I needed.
//
//=======================================================================================
// Provide mechanisms to:
//
// [1] Invoke a non-static member of a class as a callback function,
//   using a callback registry object instantiated once per class.
//
// [2] Communicate between windows objects of different types by using a
// simple Signal/Slot Mechanism for publishing signals, emitting signals,
//   and connecting signals to slots.
//
// Author: Bill Moore (wm2015email a t gmail.com)
// Data:   11/18/2016
//=======================================================================================

// Requires: C++11
#include <vector>

using std::vector;

// generic callback data
template<typename classname>
struct d${
  classname*     inst;
  void (classname::*func)(Fl_Widget*, void*);
  void*          data;
  Fl_Widget*     widget;
};

// generic callback function
template<typename classname>
void x$(Fl_Widget* widget, void* data) {
  d$<classname>* cb_data = (d$<classname>*)data;
  cb_data->widget = widget;
  // given a class instances, call a non-static member function of the class
  (cb_data->inst->*(cb_data->func))(cb_data->widget, cb_data->data);
}

// CALLBACK SLOT
class cb_slot {
public:
  Fl_Callback* func;
  void*        data;
};

// CALLBACK REGISTERY - Keep track of callback data using RAII
template<typename classname>
class cb_registry {
public:

  using datatype = d$<classname>;

  cb_registry(classname* inst) : inst{inst} {}

  ~cb_registry() {
      for (datatype* elem : keeper) {
        delete elem;
    }
  }

  Fl_Callback* func() {
      return (Fl_Callback*) x$<classname>;
  }

  void* data(
    void (classname::*fptr)(Fl_Widget*, void*),
    void*          data)
  {
    datatype* dataptr = new datatype {inst, fptr, data, 0};
    keeper.push_back(dataptr);
    return (void*) dataptr;
  }

  const cb_slot slot(
    void (classname::*fptr)(Fl_Widget*, void*),
    void*          dptr)
  {
     cb_slot slot1;
     slot1.func = func();
     slot1.data = data(fptr, dptr);
     return slot1; // return copy of slot
  }

private:
  classname*         inst;
  vector<datatype*>  keeper;
};

// CALLBACK SIGNAL
class cb_signal {
  public:
    cb_signal(Fl_Widget* widget) : widget{widget}, func{nullptr}, data{nullptr} {}

    ~cb_signal() {}

    void connect(const cb_slot& slot) {
        func = slot.func;
        data = slot.data;
    }

    void connect(Fl_Callback* callback, void* data) {
        func = callback;
        data = data;
    }

    void emit() {
        if(func) func(widget, data);
    }

  private:
    Fl_Widget*   widget;
    Fl_Callback* func;
    void*        data;
};

#endif


------=_Part_6602_1406022528.1479570238330
Content-Type: text/x-c++src; charset=US-ASCII; name=win_first.cpp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=win_first.cpp
X-Attachment-Id: a23b77f7-b72c-4ac9-88c7-7fb5dc246a32
Content-ID: <a23b77f7-b72c-4ac9-88c7-7fb5dc246a32>

#include <Fl/Fl_Menu_Item.H>
#include <Fl/Fl_Menu_Bar.H>
#include <Fl/Fl_Input.H>
#include <FL/fl_ask.H> // fl_input
#include <functional>

#include "win_first.h"

EditorWindow::EditorWindow(int w, int h, const char* t) :
    Fl_Double_Window{w, h, t}
{
    create_menu();
    textbuf  = new Fl_Text_Buffer();
    editor   = new Fl_Text_Editor (0, 30, w, h-30);
    editor->buffer(textbuf);
    editor->textfont(FL_COURIER);
    textbuf->add_modify_callback(changed_cb_static, (void*)this);
    textbuf->call_modify_callbacks ();

    set_title();
}


void EditorWindow::create_menu()
{

  using namespace std::placeholders;

//using std::placeholders::_1;
//    std::function<void(int)> f_add_display2 = std::bind( &Foo::print_add, foo, _1 );


    std::function<void(Fl_Widget*, void*)> callback = std::bind(&EditorWindow::cb_new, this, _1, _2);

    //auto f = [&](Fl_Widget* w, void* d){cb_new(w,d);};
    //auto f = [](Fl_Widget* w, void* d){cout << "hi\n";};

    menuitems = new Fl_Menu_Item[100]
    {
        { "&File",            0,                           0,                0,                        FL_SUBMENU },

//        { "&New File",        0,                         callback(),  0,        0},

        { "&New File",        0,                           cb.func(), cb.data(cb_new,       nullptr),   0},
//      { "&New File",        0,                           f,     0,   0},

        { "&Open File...",    FL_COMMAND + 'o',            cb.func(), cb.data(cb_open,     nullptr),   0},
        { "&Insert File...",  FL_COMMAND + 'i',            cb.func(), cb.data(cb_insert,   nullptr),   FL_MENU_DIVIDER},
        { "&Save File",       FL_COMMAND + 's',            cb.func(), cb.data(cb_save,     nullptr),   0},
        { "Save File &As...", FL_COMMAND + FL_SHIFT + 's', cb.func(), cb.data(cb_saveas,   nullptr),   FL_MENU_DIVIDER},
        { "New &View",        FL_ALT + 'v',                cb.func(), cb.data(cb_view,     nullptr),   0},
        { "&Close View",      FL_COMMAND + 'w',            cb.func(), cb.data(cb_close,    nullptr),   FL_MENU_DIVIDER},
        { "E&xit",            FL_COMMAND + 'q',            cb.func(), cb.data(cb_quit,     nullptr),   0},
        { 0 },

        { "&Edit",            0,                           0,                0,                        FL_SUBMENU },
        { "&Undo",            FL_COMMAND + 'z',            cb.func(), cb.data(cb_undo,     nullptr),   FL_MENU_DIVIDER},
        { "Cu&t",             FL_COMMAND + 'x',            cb.func(), cb.data(cb_cut,      nullptr),   0},
        { "&Copy",            FL_COMMAND + 'c',            cb.func(), cb.data(cb_copy,     nullptr),   0},
        { "&Paste",           FL_COMMAND + 'v',            cb.func(), cb.data(cb_paste,    nullptr),   0},
        { "&Delete",          0,                           cb.func(), cb.data(cb_delete,   nullptr),   0},
        { 0 },

        { "&Search",          0,                           0,         0,                               FL_SUBMENU},
        { "&Find...",         FL_COMMAND + 'f',            cb.func(), cb.data(cb_find,     nullptr),   0},
        { "F&ind Again",      FL_COMMAND + 'g',            cb.func(), cb.data(cb_find2,    nullptr),   0},
        { "&Replace...",      FL_COMMAND + 'r',            cb.func(), cb.data(cb_replace,  nullptr),   0},
        { "Re&place Again",   FL_COMMAND + 't',            cb.func(), cb.data(cb_replace2, nullptr),   0},
        { 0 },

        { 0 }
    };

    menubar = new Fl_Menu_Bar (0, 0, 640, 30);
    menubar->copy (menuitems);
}


void EditorWindow::set_title()
{

    if (!filename[0])
        title = "Untitled";
    else {

        title = filename;
        const size_t last_slash_idx = title.find_last_of("\\/");
        if (std::string::npos != last_slash_idx) {
            title.erase(0, last_slash_idx + 1);
        }
    }

    if (changed) {
        title += " (modified)";
    }

    label (title.c_str());
}



void EditorWindow::cb_copy(Fl_Widget* widget, void* data)
{
    Fl_Text_Editor::kf_copy (0, editor);
}

void EditorWindow::cb_cut(Fl_Widget*, void* data)
{
    Fl_Text_Editor::kf_cut (0, editor);
}

void EditorWindow::cb_delete(Fl_Widget*, void* data)
{
    textbuf->remove_selection ();
}

void EditorWindow::cb_find(Fl_Widget* w, void* v)
{
    const char *val;

    val = fl_input ("Search String:", search);
    if (val != NULL)
    {
        // User entered a string - go find it!
        strcpy(search, val);
        cb_find2(w, v);
    }
}



void EditorWindow::cb_find2(Fl_Widget* w, void* v)
{
    if (search[0] == '\0')
    {
        // Search string is blank; get a new one...
        cb_find(w, v);
        return;
    }

    int pos = editor->insert_position();
    int found = textbuf->search_forward (pos, search, &pos);
    if (found)
    {
        // Found a match; select and update the position...
        textbuf->select (pos, pos+strlen(search));
        editor->insert_position(pos+strlen(search));
        editor->show_insert_position();
    }
    else fl_alert ("No occurrences of \'%s\' found!", search);
}

void EditorWindow::cb_paste(Fl_Widget* w, void* v) {
    Fl_Text_Editor::kf_paste (0, editor);
}



void EditorWindow::changed_cb_static(int, int nInserted, int nDeleted, int, const char*, void* v) {
 EditorWindow *w = (EditorWindow *)v;
 w->changed_cb(nInserted, nDeleted);
}

void EditorWindow::changed_cb(int nInserted, int nDeleted)
{
    if ((nInserted || nDeleted) && !loading)
        changed = 1;

    set_title();

    if (loading)
        editor->show_insert_position();
}

void EditorWindow::cb_replace_all  (Fl_Widget* widget, void* data) {
  cout << "EW:cb_replace_all\n";
}

void EditorWindow::cb_replace_next (Fl_Widget* widget, void* data) {
  cout << "EW:cb_replace_next\n";
}

void EditorWindow::cb_replace  (Fl_Widget* widget, void* data) {
        cout << "replace\n";
        ReplaceWindow* w = new ReplaceWindow();
        w->sig_replace_all.connect  (cb.slot(cb_replace_all,  nullptr));
        w->sig_replace_next.connect (cb.slot(cb_replace_next, nullptr));
        w->show();

        while (w->shown()) Fl::wait();
        cout << "replace done\n";
}

void EditorWindow::cb_replace2 (Fl_Widget* widget, void* data) {
    cout << "replace2\n";
}


------=_Part_6602_1406022528.1479570238330
Content-Type: text/x-chdr; charset=US-ASCII; name=win_first.h
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=win_first.h
X-Attachment-Id: 344d7475-078f-47ba-b54e-6845f356bab0
Content-ID: <344d7475-078f-47ba-b54e-6845f356bab0>

#include <FL/Fl.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Text_Editor.H>
#include <FL/Fl_Menu_Bar.H>
#include <Fl/Fl_Window.H>
#include <Fl/Fl_Double_Window.H>
#include <Fl/Fl_Text_Editor.H>
#include <iostream>
#include <string>

using std::cout;
using std::string;

#include "fl_callback.h"

class EditorWindow;

class ReplaceWindow : public Fl_Window {;
public:

  cb_registry<ReplaceWindow>  cb {this};

  cb_signal     sig_replace_all  {this};
  cb_signal     sig_replace_next {this};

  Fl_Input*   inp_find;
  Fl_Input*   inp_with;
  Fl_Button*  btn_all;
  Fl_Button*  btn_next;
  Fl_Button*  btn_cancel;

  ReplaceWindow() : Fl_Window{300, 105, "Replace"}  {
    inp_find   = new Fl_Input  (70,  10,  200, 25, "Find:");
    inp_with   = new Fl_Input  (70,  40,  200, 25, "Replace:");
    btn_all    = new Fl_Button (10,  70,  90,  25, "Replace All");
    btn_next   = new Fl_Button (105, 70,  120, 25, "Replace Next");
    btn_cancel = new Fl_Button (230, 70,  60,  25, "Cancel");

    btn_all->callback    (cb.func(),  cb.data(cb_btn_all,    nullptr));
    btn_next->callback   (cb.func(),  cb.data(cb_btn_next,   nullptr));
    btn_cancel->callback (cb.func(),  cb.data(cb_btn_cancel, nullptr));
  }

  ~ReplaceWindow() {
    delete inp_find;
    delete inp_with;
    delete btn_all;
    delete btn_next;
    delete btn_cancel;
  }

  void cb_btn_all(Fl_Widget* , void* data) {
      cout << "cb_btn_all\n";
       sig_replace_all.emit();
  }

  void cb_btn_next(Fl_Widget* , void* data) {
      cout << "cb_btn_next\n";
       sig_replace_next.emit();
  }

  void cb_btn_cancel(Fl_Widget* , void* data) {
      cout << "cb_btn_cancel\n";
  }

};

class EditorWindow : public Fl_Double_Window
{
public:

  EditorWindow(int w, int h, const char* t);
  ~EditorWindow() {}

    void create_menu();
    cb_registry<EditorWindow>  cb {this};
    Fl_Window*                 replace_dlg;
    Fl_Input*                  replace_find;
    Fl_Input*                  replace_with;
    Fl_Button*                 replace_all;
    Fl_Return_Button*          replace_next;
    Fl_Button*                 replace_cancel;
    Fl_Text_Editor*            editor;
    Fl_Text_Buffer*            textbuf;
    Fl_Menu_Item*              menuitems;
    Fl_Menu_Bar*               menubar;
    char                       search[256];
    int                        changed       = 0;
    string                     filename {""};
    string                     title {""};
    int                        loading {0};

    void set_title   ();

    void cb_new      (Fl_Widget* widget, void* data) {cout << "new\n";}
    void cb_open     (Fl_Widget* widget, void* data) {cout << "open\n";}
    void cb_insert   (Fl_Widget* widget, void* data) {cout << "insert\n";}
    void cb_save     (Fl_Widget* widget, void* data) {cout << "save\n";}
    void cb_saveas   (Fl_Widget* widget, void* data) {cout << "saveas\n";}
    void cb_view     (Fl_Widget* widget, void* data) {cout << "view\n";}
    void cb_close    (Fl_Widget* widget, void* data) {cout << "close\n";}
    void cb_quit     (Fl_Widget* widget, void* data) {cout << "quit\n";}
    void cb_undo     (Fl_Widget* widget, void* data) {cout << "undo\n";}
    void cb_cut      (Fl_Widget* widget, void* data);
    void cb_copy     (Fl_Widget* widget, void* data);
    void cb_paste    (Fl_Widget* widget, void* data);
    void cb_delete   (Fl_Widget* widget, void* data);
    void cb_find     (Fl_Widget* widget, void* data);
    void cb_find2    (Fl_Widget* widget, void* data);
    void cb_replace  (Fl_Widget* widget, void* data);
    void cb_replace2 (Fl_Widget* widget, void* data);

    void cb_replace_all  (Fl_Widget* widget, void* data);
    void cb_replace_next (Fl_Widget* widget, void* data);

    void changed_cb(int nInserted, int nDeleted);
    static void changed_cb_static(int, int nInserted, int nDeleted, int, const char*, void* v);
};


------=_Part_6602_1406022528.1479570238330--

.


Author: wm2015email@gmail.com
Date: Sat, 19 Nov 2016 07:46:19 -0800 (PST)
Raw View
------=_Part_6720_6143837.1479570380076
Content-Type: multipart/alternative;
 boundary="----=_Part_6721_745578688.1479570380076"

------=_Part_6721_745578688.1479570380076
Content-Type: text/plain; charset=UTF-8

granted I can hack around that problem using the method above... but i
prefer it built into the compile and hidden so that its more optimised and
so that nobody is blaming me for inserting a performance bottle neck by
calling a function that calls a function... if the compiler does that
magic,,then its the compiler writer's fault if it does that,,,

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52ced74e-2b77-47cc-8db4-2609e8bb6e12%40isocpp.org.

------=_Part_6721_745578688.1479570380076
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">granted I can hack around that problem using the method ab=
ove... but i prefer it built into the compile and hidden so that its more o=
ptimised and so that nobody is blaming me for inserting a performance bottl=
e neck by calling a function that calls a function... if the compiler does =
that magic,,then its the compiler writer&#39;s fault if it does that,,,<br>=
</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/52ced74e-2b77-47cc-8db4-2609e8bb6e12%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/52ced74e-2b77-47cc-8db4-2609e8bb6e12=
%40isocpp.org</a>.<br />

------=_Part_6721_745578688.1479570380076--

------=_Part_6720_6143837.1479570380076--

.


Author: Viacheslav Usov <via.usov@gmail.com>
Date: Mon, 21 Nov 2016 13:06:25 +0100
Raw View
--001a11412d3c2eeeec0541ce7ca4
Content-Type: text/plain; charset=UTF-8

On Sat, Nov 19, 2016 at 4:38 PM, <wm2015email@gmail.com> wrote:

> I always wonder why they just don't add an implicit type conversion for
"function pointers to non-static class methods" that automatically creates
a temporary function in the global scope that exactly matches the function
parameters for the class method except its a regular non-class function,
and then to have this temporary global static function call the specific
non-static method in the class.

What is a "temporary function in the global scope"? Temporary objects in
today's C++ are either in an expression scope, or lifetime-extended by
references. Because your proposal is about an implicit conversion, lifetime
extension by references would not be applicable, so the lifetime of your
temporary object would be that of an expression, which is probably too
short for most practical cases.

Another obstacle is that per the C++ standard, a program manipulates
objects, and functions are explicitly not objects, so a "temporary
function" is something completely alien to the standard.

Cheers,
V.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg0Yffu1z5iW7PHA4dw%2Bz9g1SmEMXdcAcQUKv62wUfEnaA%40mail.gmail.com.

--001a11412d3c2eeeec0541ce7ca4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
at, Nov 19, 2016 at 4:38 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:wm201=
5email@gmail.com" target=3D"_blank">wm2015email@gmail.com</a>&gt;</span> wr=
ote:</div><div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">&=
gt; I always wonder why they just don&#39;t add an implicit type conversion=
 for &quot;function pointers to non-static class methods&quot; that automat=
ically creates a temporary function in the global scope that exactly matche=
s the function parameters for the class method except its a regular non-cla=
ss function, and then to have this temporary global static function call th=
e specific non-static method in the class.</div><div class=3D"gmail_quote">=
<br></div><div class=3D"gmail_quote">What is a &quot;temporary function in =
the global scope&quot;? Temporary objects in today&#39;s C++ are either in =
an expression scope, or lifetime-extended by references. Because your propo=
sal is about an implicit conversion, lifetime extension by references would=
 not be applicable, so the lifetime of your temporary object would be that =
of an expression, which is probably too short for most practical cases.</di=
v><div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">Another o=
bstacle is that per the C++ standard, a program manipulates objects, and fu=
nctions are explicitly not objects, so a &quot;temporary function&quot; is =
something completely alien to the standard.</div><div class=3D"gmail_quote"=
><br></div><div class=3D"gmail_quote">Cheers,</div><div class=3D"gmail_quot=
e">V.</div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAA7YVg0Yffu1z5iW7PHA4dw%2Bz9g1SmEMXd=
cAcQUKv62wUfEnaA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg0Yffu1z5=
iW7PHA4dw%2Bz9g1SmEMXdcAcQUKv62wUfEnaA%40mail.gmail.com</a>.<br />

--001a11412d3c2eeeec0541ce7ca4--

.


Author: "D. B." <db0451@gmail.com>
Date: Mon, 21 Nov 2016 12:09:26 +0000
Raw View
--001a1130cf06fd00f60541ce865f
Content-Type: text/plain; charset=UTF-8

I guess they didn't really mean "temporary", but rather compiler-generated.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFL2EA6LseyC6zxnPNZiWHmo_aSxm9bACY0Fo0%2Bv3BdQA%40mail.gmail.com.

--001a1130cf06fd00f60541ce865f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I guess they didn&#39;t really mean &quot;temporary&quot;,=
 but rather compiler-generated.<br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhFL2EA6LseyC6zxnPNZiWHmo_aSxm9b=
ACY0Fo0%2Bv3BdQA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFL2EA6Ls=
eyC6zxnPNZiWHmo_aSxm9bACY0Fo0%2Bv3BdQA%40mail.gmail.com</a>.<br />

--001a1130cf06fd00f60541ce865f--

.


Author: Viacheslav Usov <via.usov@gmail.com>
Date: Mon, 21 Nov 2016 14:12:33 +0100
Raw View
--f403045ec286b6c8980541cf6859
Content-Type: text/plain; charset=UTF-8

On Mon, Nov 21, 2016 at 1:09 PM, D. B. <db0451@gmail.com> wrote:

> I guess they didn't really mean "temporary", but rather
compiler-generated.

No, that cannot be compiler-generated. The generated function will have to
have at least the current value of the this pointer embedded into it, at
least in the situations when the compiler cannot optimise that away. So the
functions will have to be generated (and destructed) at runtime,
essentially making functions first-class objects, which, as I said, would
be a pretty big change in the C++ philosophy.

Cheers,
V.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg2man2zq0CHJ-cLrC41FpAFad4MVgWviee7Lbdrm4cVQw%40mail.gmail.com.

--f403045ec286b6c8980541cf6859
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Nov 21, 2016 at 1:09 PM, D. B. <span dir=3D"ltr">&lt;<a href=3D"mailto:=
db0451@gmail.com" target=3D"_blank">db0451@gmail.com</a>&gt;</span> wrote:<=
/div><div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">&gt; I=
 guess they didn&#39;t really mean &quot;temporary&quot;, but rather compil=
er-generated.</div><div class=3D"gmail_quote"><br></div><div class=3D"gmail=
_quote">No, that cannot be compiler-generated. The generated function will =
have to have at least the current value of the this pointer embedded into i=
t, at least in the situations when the compiler cannot optimise that away. =
So the functions will have to be generated (and destructed) at runtime, ess=
entially making functions first-class objects, which, as I said, would be a=
 pretty big change in the C++ philosophy.</div><div class=3D"gmail_quote"><=
br></div><div class=3D"gmail_quote">Cheers,</div><div class=3D"gmail_quote"=
>V.</div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAA7YVg2man2zq0CHJ-cLrC41FpAFad4MVgWv=
iee7Lbdrm4cVQw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg2man2zq0CH=
J-cLrC41FpAFad4MVgWviee7Lbdrm4cVQw%40mail.gmail.com</a>.<br />

--f403045ec286b6c8980541cf6859--

.


Author: "D. B." <db0451@gmail.com>
Date: Mon, 21 Nov 2016 13:24:31 +0000
Raw View
--001a11423f44829b360541cf9332
Content-Type: text/plain; charset=UTF-8

On Mon, Nov 21, 2016 at 1:12 PM, Viacheslav Usov <via.usov@gmail.com> wrote:

>
> No, that cannot be compiler-generated. The generated function will have to
> have at least the current value of the this pointer embedded into it, at
> least in the situations when the compiler cannot optimise that away. So the
> functions will have to be generated (and destructed) at runtime,
> essentially making functions first-class objects, which, as I said, would
> be a pretty big change in the C++ philosophy.
>
>
Indeed, thanks for the correction.

I agree that this would be a large change, for insufficient benefit IMO. I
have no problem using a lambda or other functor for this. The OP said

Lamba's just seems like a the less obvious solution in my opinion.


....and it must just be me, but usually when I have a problem of this sort,
lambdas are the *most* obvious solution. ;-)

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhGtMw-7GVjjsp3PTN8GuhRhL4NY%3DguCosQK1d3mU0oNXg%40mail.gmail.com.

--001a11423f44829b360541cf9332
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Nov 21, 2016 at 1:12 PM, Viacheslav Usov <span dir=3D"ltr">&lt;<a href=
=3D"mailto:via.usov@gmail.com" target=3D"_blank">via.usov@gmail.com</a>&gt;=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div di=
r=3D"ltr"><br><div class=3D"gmail_extra"><span class=3D"gmail-"></span><div=
 class=3D"gmail_quote">No, that cannot be compiler-generated. The generated=
 function will have to have at least the current value of the this pointer =
embedded into it, at least in the situations when the compiler cannot optim=
ise that away. So the functions will have to be generated (and destructed) =
at runtime, essentially making functions first-class objects, which, as I s=
aid, would be a pretty big change in the C++ philosophy.</div><div class=3D=
"gmail_quote"><br></div></div></div></blockquote><div><br></div><div>Indeed=
, thanks for the correction.<br><br></div><div>I agree that this would be a=
 large change, for insufficient benefit IMO. I have no problem using a lamb=
da or other functor for this. The OP said<br><br><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);padding-left:1ex">Lamba&#39;s just seems like a the less obvious solu=
tion in my opinion.</blockquote><div><br></div><div>...and it must just be =
me, but usually when I have a problem of this sort, lambdas are the <i>most=
</i> obvious solution. ;-) <br></div></div></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhGtMw-7GVjjsp3PTN8GuhRhL4NY%3Dg=
uCosQK1d3mU0oNXg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhGtMw-7GV=
jjsp3PTN8GuhRhL4NY%3DguCosQK1d3mU0oNXg%40mail.gmail.com</a>.<br />

--001a11423f44829b360541cf9332--

.