
AMDG I was going to post a response to Lorenzo's question using phoenix, but I ran into a few issues. The initial version I wrote compiles, but doesn't work. #include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <iostream> #include <vector> #include <algorithm> int main() { double sum = 0.0; int factor = 10; using namespace boost::phoenix; using namespace boost::phoenix::placeholders; std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, ref(std::cout) << "Summed: " << ref(sum) << std::endl )); return 0; } This is because the overloaded comma operator is provided by statement.hpp, not operator.hpp as I had erroneously assumed. Can we please make sure that the built-in comma operator can't get silently called? After I added #include <boost/phoenix/statement.hpp>, it still doesn't compile and I have no idea how to make it compile, because it tries to copy std::cout. I'm guessing that the result of the comma operator is being deduced as a non-reference, since the cout part compiles fine by itself. In Christ, Steven Watanabe

On 03/26/2011 04:07 PM, Steven Watanabe wrote:
AMDG
I was going to post a response to Lorenzo's question using phoenix, but I ran into a few issues.
The initial version I wrote compiles, but doesn't work.
#include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <iostream> #include <vector> #include <algorithm>
int main() { double sum = 0.0; int factor = 10;
using namespace boost::phoenix; using namespace boost::phoenix::placeholders;
std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, ref(std::cout) << "Summed: " << ref(sum) << std::endl )); return 0; }
This is because the overloaded comma operator is provided by statement.hpp, not operator.hpp as I had erroneously assumed. Can we please make sure that the built-in comma operator can't get silently called?
After I added #include <boost/phoenix/statement.hpp>, it still doesn't compile and I have no idea how to make it compile, because it tries to copy std::cout. I'm guessing that the result of the comma operator is being deduced as a non-reference, since the cout part compiles fine by itself.
In Christ, Steven Watanabe _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Unfortunately this is a common problem (statement.h). I agree that the silent built-in should be changed. I have had problems with std::endl and phoenix in the past... this version compiles fine: ----------------- #include <boost/phoenix/phoenix.hpp> #include <boost/phoenix/statement.hpp> #include <iostream> #include <vector> #include <algorithm> int main() { double sum = 0.0; int factor = 10; using namespace boost::phoenix; using namespace boost::phoenix::placeholders; std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, std::cout << "Summed: " << ref(sum) << "\n" ) ); return 0; } -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

AMDG On 03/26/2011 04:26 PM, Michael Caisse wrote:
Unfortunately this is a common problem (statement.h). I agree that the silent built-in should be changed.
I have had problems with std::endl and phoenix in the past... this version compiles fine:
It doesn't compile with VS 2010.
-----------------
#include <boost/phoenix/phoenix.hpp> #include <boost/phoenix/statement.hpp> #include <iostream> #include <vector> #include <algorithm>
int main() { double sum = 0.0; int factor = 10;
using namespace boost::phoenix; using namespace boost::phoenix::placeholders;
std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, std::cout << "Summed: " << ref(sum) << "\n" ) ); return 0; }
In Christ, Steven Watanabe

On 03/26/2011 04:33 PM, Steven Watanabe wrote:
AMDG
On 03/26/2011 04:26 PM, Michael Caisse wrote:
Unfortunately this is a common problem (statement.h). I agree that the silent built-in should be changed.
I have had problems with std::endl and phoenix in the past... this version compiles fine:
It doesn't compile with VS 2010.
Hmmmm... I only have clang and gcc available right now. I'll take a look later when I have access to an MS compiler. michael -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

On 03/26/2011 04:39 PM, Michael Caisse wrote:
On 03/26/2011 04:33 PM, Steven Watanabe wrote:
AMDG
On 03/26/2011 04:26 PM, Michael Caisse wrote:
Unfortunately this is a common problem (statement.h). I agree that the silent built-in should be changed.
I have had problems with std::endl and phoenix in the past... this version compiles fine:
It doesn't compile with VS 2010.
Hmmmm...
I only have clang and gcc available right now. I'll take a look later when I have access to an MS compiler.
michael
Hi Steven - Hartmut just gave it a try on VS 2010 and it compiled/worked fine for him. We are both using Phoenix V3 from the trunk. Are you on a different version? What type of error(s) are you seeing? michael -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

AMDG On 03/26/2011 04:49 PM, Michael Caisse wrote:
On 03/26/2011 04:39 PM, Michael Caisse wrote:
On 03/26/2011 04:33 PM, Steven Watanabe wrote:
On 03/26/2011 04:26 PM, Michael Caisse wrote:
Unfortunately this is a common problem (statement.h). I agree that the silent built-in should be changed.
I have had problems with std::endl and phoenix in the past... this version compiles fine:
It doesn't compile with VS 2010.
Hmmmm...
I only have clang and gcc available right now. I'll take a look later when I have access to an MS compiler.
michael
Hi Steven -
Hartmut just gave it a try on VS 2010 and it compiled/worked fine for him. We are both using Phoenix V3 from the trunk. Are you on a different version? What type of error(s) are you seeing?
trunk@70605
cl -EHsc -ID:/boost/trunk scratch.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.
scratch.cpp C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\ostream(604) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' with [ _Elem=char, _Traits=std::char_traits<char> ] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\ios(176): see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios' with [ _Elem=char, _Traits=std::char_traits<char> ] This diagnostic occurred in the compiler generated function 'std::basic_ostream<_Elem,_Traits>::basic_ostream(const std::basic_ostream<_Elem,_Traits> &) ' with [ _Elem=char, _Traits=std::char_traits<char> ]
type scratch.cpp #include <boost/phoenix/phoenix.hpp> #include <boost/phoenix/statement.hpp> #include <iostream> #include <vector> #include <algorithm>
int main() { double sum = 0.0; int factor = 10; using namespace boost::phoenix; using namespace boost::phoenix::placeholders; std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, std::cout << "Summed: " << ref(sum) << "\n" ) ); return 0; } In Christ, Steven Watanabe

On 03/26/2011 05:12 PM, Steven Watanabe wrote:
AMDG
On 03/26/2011 04:49 PM, Michael Caisse wrote:
Hi Steven -
Hartmut just gave it a try on VS 2010 and it compiled/worked fine for him. We are both using Phoenix V3 from the trunk. Are you on a different version? What type of error(s) are you seeing?
trunk@70605
cl -EHsc -ID:/boost/trunk scratch.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.
Hartmut is on SP1: V16.00.40219.01 I've now become the messenger so I'm going to step out of the conversation and let somebody with VC10 access pick it up if there are still issues. michael -- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

On Sunday, March 27, 2011 12:07:04 AM Steven Watanabe wrote:
AMDG
I was going to post a response to Lorenzo's question using phoenix, but I ran into a few issues.
The initial version I wrote compiles, but doesn't work.
#include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <iostream> #include <vector> #include <algorithm>
int main() { double sum = 0.0; int factor = 10;
using namespace boost::phoenix; using namespace boost::phoenix::placeholders;
std::vector<double> v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; std::for_each(v.begin(), v.end(), ( ref(sum) += factor * _1, ref(std::cout) << "Summed: " << ref(sum) << std::endl )); return 0; }
This is because the overloaded comma operator is provided by statement.hpp, not operator.hpp as I had erroneously assumed. Can we please make sure that the built-in comma operator can't get silently called?
Thanks for the heads up. I can add the operator, for actor at all times, but keep it disabled (with a compile error) untile boost/phoenix/statement.hpp is included.
After I added #include <boost/phoenix/statement.hpp>, it still doesn't compile and I have no idea how to make it compile, because it tries to copy std::cout. I'm guessing that the result of the comma operator is being deduced as a non-reference, since the cout part compiles fine by itself.
Has this issue been resolved now? Looking at the test runner matrix the MSVC10 runner doesn't have problems like these. Maybe we should add a testcase for that ... Regards, Thomas
participants (3)
-
Michael Caisse
-
Steven Watanabe
-
Thomas Heller