what happened to the
obfuscated "Hello world!" application
??!?!??!?!?!?1
:confused:
Printable View
what happened to the
obfuscated "Hello world!" application
??!?!??!?!?!?1
:confused:
Code:#include <iostream>
#include <list>
#include <boost/any.hpp>
#include <algorithm>
using namespace std;
typedef list<boost::any> lany;
template <typename T>void Larry(T t){}
template <>void Larry(int t){if(t) cout<<"H"; else cout<<"d";}
template <>void Larry(float t){if(!t) cout<<"e"; else cout<<"l";}
template <>void Larry(bool t){if(t) cout<<"o"; else cout<<" ";}
template <>void Larry(double t){if(t) cout<<"w"; else cout<<"r";}
template <>void Larry(char t){if(t) cout<<"!"; else cout<<"\n";}
void Jimmy( const boost::any & Any)
{
try{Larry(boost::any_cast<int> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<float> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<bool> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<double>(Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<char> (Any));} catch(boost::bad_any_cast&){}
}
int main()
{
lany Lany;
Lany.push_back(boost::any(1));
Lany.push_back(boost::any(0.0f));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(true));
Lany.push_back(boost::any(false));
Lany.push_back(boost::any(1.0));
Lany.push_back(boost::any(true));
Lany.push_back(boost::any(0.0));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(0));
Lany.push_back(boost::any('x'));
Lany.push_back(boost::any('\0'));
for_each(Lany.begin(), Lany.end(), Jimmy);
return 0;
}
well you got the purple part which other part are you not getting...Quote:
Originally posted by galathaea
Hmm, I think I still don't get it.....
Gabriel, what does this program mean ?...ahmm.. what is the include<... .hpp > used for ?Quote:
Originally posted by Gabriel Fleseriu
Code:#include <iostream>
#include <list>
#include <boost/any.hpp>
#include <algorithm>
using namespace std;
typedef list<boost::any> lany;
template <typename T>void Larry(T t){}
template <>void Larry(int t){if(t) cout<<"H"; else cout<<"d";}
template <>void Larry(float t){if(!t) cout<<"e"; else cout<<"l";}
template <>void Larry(bool t){if(t) cout<<"o"; else cout<<" ";}
template <>void Larry(double t){if(t) cout<<"w"; else cout<<"r";}
template <>void Larry(char t){if(t) cout<<"!"; else cout<<"\n";}
void Jimmy( const boost::any & Any)
{
try{Larry(boost::any_cast<int> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<float> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<bool> (Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<double>(Any));} catch(boost::bad_any_cast&){}
try{Larry(boost::any_cast<char> (Any));} catch(boost::bad_any_cast&){}
}
int main()
{
lany Lany;
Lany.push_back(boost::any(1));
Lany.push_back(boost::any(0.0f));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(true));
Lany.push_back(boost::any(false));
Lany.push_back(boost::any(1.0));
Lany.push_back(boost::any(true));
Lany.push_back(boost::any(0.0));
Lany.push_back(boost::any(1.0f));
Lany.push_back(boost::any(0));
Lany.push_back(boost::any('x'));
Lany.push_back(boost::any('\0'));
for_each(Lany.begin(), Lany.end(), Jimmy);
return 0;
}
Thank you veru much...
Regards
As (almost) every program in this thread, this one also prints "Hello world!". I find it rather funny than obfuscated. The extension ".hpp" is a header extension. The boost library (www.boost.org) uses it.Quote:
Originally posted by hometown
Gabriel, what does this program mean ?...ahmm.. what is the include<... .hpp > used for ?
Thank you veru much...
Regards
Does this answer your question, or do you want to know how it works?
You mean if I would like to use such a .hpp file I will have to download it from boost ?
But what is that header file used for ?
If you want to use any of the boost' libraries, then yes, you will have to download them from boost. That doesn't mean that you are not allowed to name your own headers "something.hpp". The extension .hpp is as good as .h -- actually it signals that the header is C++ specific (.c vs. .cpp --> .h vs. .hpp);Quote:
Originally posted by hometown
You mean if I would like to use such a .hpp file I will have to download it from boost ?
But what is that header file used for ?
<boost/any.hpp> is the header that implements the class boost::any. To make a long story short, this class can hold (nearly) any type of variable -- thus the name. Read the boost documentation if you want to know more.
:)Quote:
Originally posted by Gabriel Fleseriu
If you want to use any of the boost' libraries, then yes, you will have to download them from boost. That doesn't mean that you are not allowed to name your own headers "something.hpp". The extension .hpp is as good as .h -- actually it signals that the header is C++ specific (.c vs. .cpp --> .h vs. .hpp);
<boost/any.hpp> is the header that implements the class boost::any. To make a long story short, this class can hold (nearly) any type of variable -- thus the name. Read the boost documentation if you want to know more.
The file extension really doesn't matter, some people do like the hpp, but the standard library has no file extension. You could make up an extension and as long as your compiler knows its a header file it will compile.
I tried making a bunch of files with different extensions, and they all work fine :)Quote:
Originally posted by mwilliamson
The file extension really doesn't matter, some people do like the hpp, but the standard library has no file extension. You could make up an extension and as long as your compiler knows its a header file it will compile.
Thank you very much...
I can't find this part of the standard. What page is thisQuote:
Gabriel Fleseriu
quote:
--------------------------------------------------------------------------------
Originally posted by galathaea
Gabriel, your post is nonstandard because it assumes an ANSI character set...
--------------------------------------------------------------------------------
Bingo!
mentioned on ?
And are you talking about wchar_t /vs char or am I missing
something.
The Standard does not say that the target platform has to have an ASCII character set. For example, some IBM computers use the so called EBCDIC character set, if my memory serves me correctly. If you run my program on such a machine, it printed some bogus string.Quote:
Originally posted by mdmd
I can't find this part of the standard. What page is this
mentioned on ?
And are you talking about wchar_t /vs char or am I missing
something.
oh~~ fantastic~~
This should be fairly standard:
Code:#include <sstream>
#include <algorithm>
#include <iostream>
template <class X> class K
{
std::basic_string<X> b, s;
public:
K(const std::basic_string<X> &z) : b(z)
{
std::for_each(++(s = static_cast<std::ostringstream *>(&(std::ostringstream() << std::endl <<
"!dlrow olleH" << std::ends))->str()).rbegin(), s.rend(), *this);
}
void operator()(std::basic_string<X>::value_type &d) const
{
if(b.find(d) == std::basic_string<std::basic_string<X>::value_type>::npos) std::cout << d;
}
};
int main()
{
K<char> k("abcfgijkmnpqstuvxyz");
return 0;
}
Something easy to understand:
Code:#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
typedef vector<string> StringVector;
typedef StringVector::iterator StringVectorIterator;
typedef ostream_iterator<string> StringOstreamIterator;
int main(int argc, char* argv[])
{
int i;
const int VECTOR_SIZE = 0x05;
char limits[] = {'('-1,'7'};
char mixture[] = {0x1D, 0x27, 0x00, 0x24, 0x24, 0x18, 0x0D, 0x1B, 0x00, 0x15};
StringVector one_word(VECTOR_SIZE);
StringVector another_word(VECTOR_SIZE);
StringVectorIterator start_one_word_it, end_one_word_it;
StringVectorIterator start_another_word_it, end_another_word_it;
StringOstreamIterator out_one_word_it(cout, "");
StringOstreamIterator out_another_word_it(cout, "");
start_one_word_it = one_word.begin();
end_one_word_it = one_word.end();
start_another_word_it = another_word.begin();
end_another_word_it = another_word.end();
for(i =0; i<VECTOR_SIZE; i++)
one_word[i] = mixture[i] + 0x48;
for(; i<VECTOR_SIZE<<1; i++)
another_word[i-VECTOR_SIZE] = mixture[i] + 0x57;
for(i=0; i<limits[0]; i++, next_permutation(start_one_word_it, end_one_word_it));
for(i=0; i<limits[1]; i++, next_permutation(start_another_word_it, end_another_word_it));
copy(start_one_word_it, end_one_word_it, out_one_word_it);
cout << " ";
copy(start_another_word_it, end_another_word_it, out_another_word_it);
cout << "!" << endl ;
return 0;
}