
all, i have mingw g++ version 3.4.2 i got boost compiled and installed on c:\Boost my simple app does not link. Error Message is - C:/DOCUME~1/208004~1/LOCALS~1/Temp/ccK6caaa.o(.text$_ZN5boost15program_options16validation_errorC1ERKSs[boost::program_options::validation_error::validation_error(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x53):hello.cpp: variable 'vtable for boost::program_options::validation_error' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details. I cannot seem to find such a switch for ld. also - I am using make. should i be using jam (or bjam?) for my app. If these are in addressed some FAQ please point me. regards srini DISCLAIMER: This e-mail and any attachment is intended only for the exclusive and confidential use of the addressee(s). If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify the sender by return e-mail immediately and delete the message from your computer without making any copies. Please see http://www.ge.com.au/help/email_privacy_policy.html for information about our privacy practices.

i have mingw g++ version 3.4.2
i got boost compiled and installed on c:\Boost
my simple app does not link.
I cannot seem to find such a switch for ld.
This is a compiler question: you need to pass -lname-of-library to the compiler's link line, you may also need -Lpath-to-libraries, both of which appear *after* the object files on the command line. Alternatively you could pass the full name of the library to link against "as if" it were another object file. In any case you'll find all this in the gcc documentation. John.

On Wed, 30 Mar 2005 11:03:56 +0100, John Maddock wrote:
i have mingw g++ version 3.4.2
i got boost compiled and installed on c:\Boost
my simple app does not link.
This is a compiler question: you need to pass -lname-of-library to the compiler's link line, you may also need -Lpath-to-libraries, both of which appear *after* the object files on the command line.
Another problem (at least, one I had) might be that when passed the -llibrary switch, ld (or gcc) looks for liblibrary.a; but the Boost libraries are created as liblibrary.lib when bjam is invoked with -sTOOLS=mingw. Creating a copy of the library and renaming it so that it had the right extension fixed my problem. Luigi

Hi, Is there a boost::switch so I can do type selection similar to mpl::if_ but with more than two types? I looked but could not find it. Or should I just use the implementation of SWITCH in the Generative Programming book? Regards, Bruce

Hi, Now that I am thinking about it, I could use mpl::map for this right? Regards, Bruce On Thu, 2005-03-31 at 09:38 -0500, Bruce Trask wrote:
Hi,
Is there a boost::switch so I can do type selection similar to mpl::if_ but with more than two types? I looked but could not find it.
Or should I just use the implementation of SWITCH in the Generative Programming book?
Regards, Bruce
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, I coded up the mpl::map versus the SWITCH approach and I am thinking that the SWITCH approach is better in this case as it shows the various mnemonic choices at the point of the SWITCH. Thoughts? Also if the SWITCH is the better way to go, it leads me to my original question as to whether there is a mpl::switch? enum tagit { one, two, three }; struct First { static void func() { cout << "First" << endl; } }; struct Second { static void func() { cout << "Second" << endl; } }; struct Third { static void func() { cout << "Third" << endl; } }; typedef mpl::map< mpl::pair<mpl::integral_c<tagit, one>, First>, mpl::pair<mpl::integral_c<tagit, two>, Second>, mpl::pair<mpl::integral_c<tagit, three>, Third> > funcchooser; template<tagit ti> void funcCaller() { SWITCH<ti, CASE<one, First, CASE<two, Second, CASE<three, Third> > >
::RET::func();
mpl::at<funcchooser, mpl::integral_c<tagit, ti> >::type::func(); } int main() { funcCaller<one>(); funcCaller<two>(); funcCaller<three>(); return 0; } Thanks, Bruce On Thu, 2005-03-31 at 10:37 -0500, Bruce Trask wrote:
Hi,
Now that I am thinking about it, I could use mpl::map for this right?
Regards, Bruce
On Thu, 2005-03-31 at 09:38 -0500, Bruce Trask wrote:
Hi,
Is there a boost::switch so I can do type selection similar to mpl::if_ but with more than two types? I looked but could not find it.
Or should I just use the implementation of SWITCH in the Generative Programming book?
Regards, Bruce
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Bruce Trask <Bruce.Trask@prismtech.com> writes:
Hi,
I coded up the mpl::map versus the SWITCH approach and I am thinking that the SWITCH approach is better in this case as it shows the various mnemonic choices at the point of the SWITCH. Thoughts?
You can't meaningfully compare the syntax of the map with something that has unspecified syntax (i.e. switch) ;-) In MPL, the closest thing to switch is currently spelled: eval_if< is_same<c1,x> , identity<r1> , eval_if< is_same<c2,x> , identity<r2> ... , eval_if< is_same<cn,x> , identity<rn> , identity<default_> > >
Also if the SWITCH is the better way to go, it leads me to my original question as to whether there is a mpl::switch?
enum tagit { one, two, three };
struct First { static void func() { cout << "First" << endl; } };
struct Second { static void func() { cout << "Second" << endl; } };
struct Third { static void func() { cout << "Third" << endl; } };
typedef mpl::map< mpl::pair<mpl::integral_c<tagit, one>, First>, mpl::pair<mpl::integral_c<tagit, two>, Second>, mpl::pair<mpl::integral_c<tagit, three>, Third> > funcchooser;
Ehm, if that's all you need to do: template <int> func_; template <> struct func_<1> { static void func() { cout << "First" << endl }}; template <> struct func_<2> { static void func() { cout << "Second" << endl }}; template <> struct func_<3> { static void func() { cout << "Third" << endl }}; template<tagit ti> void funcCaller() { func_<ti>::func(); } -- Dave Abrahams Boost Consulting www.boost-consulting.com

Hi Dave, Thanks for your input. I had a few follow up questions and requests for clarifications below: On Thu, 2005-03-31 at 14:43 -0500, David Abrahams wrote:
Bruce Trask <Bruce.Trask@prismtech.com> writes:
Hi,
I coded up the mpl::map versus the SWITCH approach and I am thinking that the SWITCH approach is better in this case as it shows the various mnemonic choices at the point of the SWITCH. Thoughts?
You can't meaningfully compare the syntax of the map with something that has unspecified syntax (i.e. switch) ;-)
The syntax of the SWITCH I was referring to is the one on page 439 of Generative Programming. I.e. template<int tag, class Case> class SWITCH { typedef typename Case::Next NextCase; enum { caseTag = Case::tag, found = (caseTag == tag || caseTag ==DEFAULT) }; public: typedef typename IF<found, typename Case::Type, typename SWITCH<tag, NextCase>::RET>::RET RET; }; template<int tag> class SWITCH<tag, NilCase> { public: typedef NilCase RET; }; with the usage syntax of SWITCH<ti, CASE<one, First, CASE<two, Second, CASE<three, Third> > >
::RET::func();
Am I missing what you are saying here?
In MPL, the closest thing to switch is currently spelled:
eval_if< is_same<c1,x> , identity<r1> , eval_if< is_same<c2,x> , identity<r2> ...
, eval_if< is_same<cn,x> , identity<rn> , identity<default_> > >
Cool. Thanks.
Also if the SWITCH is the better way to go, it leads me to my original question as to whether there is a mpl::switch?
enum tagit { one, two, three };
struct First { static void func() { cout << "First" << endl; } };
struct Second { static void func() { cout << "Second" << endl; } };
struct Third { static void func() { cout << "Third" << endl; } };
typedef mpl::map< mpl::pair<mpl::integral_c<tagit, one>, First>, mpl::pair<mpl::integral_c<tagit, two>, Second>, mpl::pair<mpl::integral_c<tagit, three>, Third> > funcchooser;
Ehm, if that's all you need to do:
template <int> func_;
template <> struct func_<1> { static void func() { cout << "First" << endl }};
template <> struct func_<2> { static void func() { cout << "Second" << endl }};
template <> struct func_<3> { static void func() { cout << "Third" << endl }};
template<tagit ti> void funcCaller() { func_<ti>::func(); }
Right. Good point. My real code is a hair more complicated but even so, I guess this is the heart of my question and it stems from page 62 of C++ Template Metaprogramming section on Type Selection, where you and Aleksey talk about the alternative of using classes with mnemonic names versus ad hoc template specializations. So my question is, do you guys have a rule of thumb for going with ad hoc specializations versus using metafunctions with mnemonic names or is it just whether is reads better at the point of the call? I have attached the source for my running example. Thanks in advance, Bruce

Bruce Trask <Bruce.Trask@prismtech.com> writes:
The syntax of the SWITCH I was referring to is the one on page 439 of Generative Programming. I.e.
<snip>
with the usage syntax of SWITCH<ti, CASE<one, First, CASE<two, Second, CASE<three, Third> > >
::RET::func();
Am I missing what you are saying here?
Where?
My real code is a hair more complicated but even so, I guess this is the heart of my question and it stems from page 62 of C++ Template Metaprogramming section on Type Selection, where you and Aleksey talk about the alternative of using classes with mnemonic names versus ad hoc template specializations.
So my question is, do you guys have a rule of thumb for going with ad hoc specializations versus using metafunctions with mnemonic names or is it just whether is reads better at the point of the call?
Personally, I do the latter, though ad hoc specializations will tend towards being harder to read. Sometimes I'm also trying to accomodate broken compilers where partial specialization doesn't work, so I end up avoiding them for that reason as well. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Bruce Trask <Bruce.Trask@prismtech.com> writes:
The syntax of the SWITCH I was referring to is the one on page 439 of Generative Programming. I.e.
<snip>
with the usage syntax of SWITCH<ti, CASE<one, First, CASE<two, Second, CASE<three, Third> > >
::RET::func();
Am I missing what you are saying here?
Where?
My real code is a hair more complicated but even so, I guess this is the heart of my question and it stems from page 62 of C++ Template Metaprogramming section on Type Selection, where you and Aleksey talk about the alternative of using classes with mnemonic names versus ad hoc template specializations.
So my question is, do you guys have a rule of thumb for going with ad hoc specializations versus using metafunctions with mnemonic names or is it just whether is reads better at the point of the call?
Personally, I do the latter, though ad hoc specializations will tend towards being harder to read so even that informal rule leads to avoiding specializations. Sometimes I'm also trying to accomodate broken compilers where partial specialization doesn't work, so I end up avoiding them for that reason as well. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Hi, I want to express a "string" value at compile time. I am assuming that I have to go with mpl::vector<char> and then convert it at runtime to its string format. I also have tried using struct TestString { static const char* getName() { return "TestStringName"; } }; and then have the user specify TestString and then I write my other code to call getName() on the type at runtime. Are these two choices the best I can hope for with regard to compile- time "string" values? Regards, Bruce

Bruce Trask <Bruce.Trask@prismtech.com> writes:
Hi,
I want to express a "string" value at compile time. I am assuming that I have to go with mpl::vector<char> and then convert it at runtime to its string format.
I think you mean vector_c< char, ... > That is basically the only way to get types that are guaranteed to be different if the contents of the string are different.
I also have tried using
struct TestString { static const char* getName() { return "TestStringName"; } };
and then have the user specify TestString and then I write my other code to call getName() on the type at runtime.
Are these two choices the best I can hope for with regard to compile- time "string" values?
char const test_string[] = "TestStringName"; A pointer or reference to test_string can be used as a template parameter as long as test_string is declared at namespace scope. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Hi David, Thanks for you response. On Thu, 2005-03-31 at 14:51 -0500, David Abrahams wrote:
char const test_string[] = "TestStringName";
A pointer or reference to test_string can be used as a template parameter as long as test_string is declared at namespace scope.
Right. Something like what's on page 41 of Vandevoorde and Josuttis? Something like #include <iostream> using namespace std; extern char const test_string[] = "TestStringName"; template<char const* name> class MyClass { public: static std::string rep() { return name; } }; int main() { cout << MyClass<test_string>::rep() << endl; return 0; } Dumb question and just so I am clear: when you say "declared at namespace scope" are you referring to the "external linkage" that David and Nicolai are referring to which keeps two string literals with the same value being the same object? Thanks, Bruce

Bruce Trask <Bruce.Trask@prismtech.com> writes:
Hi David,
Thanks for you response.
On Thu, 2005-03-31 at 14:51 -0500, David Abrahams wrote:
char const test_string[] = "TestStringName";
A pointer or reference to test_string can be used as a template parameter as long as test_string is declared at namespace scope.
Right. Something like what's on page 41 of Vandevoorde and Josuttis? Something like
<snip> Sure.
Dumb question and just so I am clear: when you say "declared at namespace scope" are you referring to the "external linkage" that David and Nicolai are referring to which keeps two string literals with the same value being the same object?
No, I mean "not declared on the stack." -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (5)
-
Bruce Trask
-
David Abrahams
-
John Maddock
-
Luigi Ballabio
-
Srinivasan, Rajagopalan (GE Healthcare)