What are some of the optimization steps that this command does
`(optimize speed (safety 0))`
Can I handcode some of these techniques in my Lisp/Scheme program?
I have this snippet of the code in my header:
class A {
private:
int player;
public:
A(int initPlayer = 0);
A(const A&);
A& operator=(const A&);
~A();
void foo() const;
friend int operator==(const A& i, const A& member) const;
};
implementation of the operator==
int operator==(const A& i, const A& member) const{
if(i.player == member.player){
return 1;
}
return 0;
}
and I need casting for this part of my code:
A *pa1 = new A(a2);
assert(i == *pa1);
i - is some int, which my function receives
I receive an error non-member function, How can I fix it? thanks in advance
I started off with C in school, went to Java and now I primarily use the P's(Php, Perl, Python) so my exposure to the lower level languages have all but disappeared. I would like to get back into it but I can never justify using C over Perl or Python. What real-world apps are being built with these languages? Any suggestions if I want to dive back in, what can I do with C/C++ that I can't easily do with Perl/Python?
I want to be able to determine the number of bytes that are in a subset of a parameter pack from 0 to a given index.
Right now I'm using a non-constexpr way of doing this. Below is my code:
template <size_t index, typename... args> struct pack_size_index;
template <size_t index, typename type_t, typename... args>
struct pack_size_index <index, type_t, args...> {
static const size_t index_v = index;
static const size_t value(void) {
if (index_v > 0) {
return sizeof(type_t) + pack_size_index<index - 1, args...>::value();
}
return 0;
}
};
template <size_t index> struct pack_size_index <index> {
static const size_t index_v = index;
static const size_t value(void) { return 0; }
};
Usage:
//output: 5 (equal to 1 + 4)
std::cout << pack_size_index<2, bool, float, int, double>::value() << std::endl;
//output: 20 (equal to 8 + 8 + 4)
std::cout << pack_size_index<3, double, double, float, int>::value() << std::endl;
This gets the job done, but this uses runtime comparison and the resulting executable increases in size rapidly whenever this is used. What's a less expensive way of doing this?
The company I work for now uses a set naming convention for their C# variables such as iSomeName for int, sSomeName for string, aSomeName for arrays, bSomeName for boolean, dSomeName for datetime and so on. My previous employer did not use the i, s, a, b and d prefixes and just named the variables a good understandable name. My impression is that these prefixes lost favor a while ago and from what I read it is not the current trend. It seems fine to me either way as long as the variable is descriptive enough to understand what it is doing but I was wondering what the now-a-day accepted practice is for naming variables?
I want to run Turbo C++ in my 64bit laptop? But I can't find any version of tc that support 64bit platforms.
Do you know of any place I can download a compatible version?
Hi All,
I have a data card, as soon as i insert the data card, i am getting the events by using wm_device_change event.
But I also want to get event, when my data connect actually connects to out side world.
I mean to say, as soon as we click on connect/disconnect button of data card,i want to get the event.
exactly speaking wanted to know, when connection is established and disconnected.
data card is vodaphone data card and i am trying to browse using that data card. what ever is the SDK, somewhere the OS should get the event of connection and disconnection to network is there any way to access that event which OS is getting. as i can see in notificaiton the changes of vodaphone connection and LAN connection
data card is a USB device having SIM within it, and can be used to access internet through GPRS.
can i know how to do this in win32 c/c++ programe.
with regards
Vinayaka Karjigi
I'm a little bit confused, can somebody please explain the main difference between those types of containers:
map
list
set
array
thanks in advanca(I'm asking about C++)
I ask this because you are probably the best audience I could think of. I program for a living, and it goes hand in hand with my personality type which is likely true for most of us, as such I live and work in the world of logic and logical decisions. A problem I have is in dealing with people that live and work in a world of emotional responses and reactions that typically make no sense, or have any real bearing on any given situation. What is the trick to dealing with these people? It is nothing but an act of futility, leading to utter exasperation dealing with people like this when attempting to get them to understand some pretty basic concepts. How do you do it?
I'm starting a new project and don't know which language to use.
My 'must have' requirements are:
Be able to run on Windows/LinuxMacOs natively (native executable) - user should be able to just run the exe (when on Windows for example) and see the results.
No runtimes/interpreters (no jvm, clr, etc) - one file download should be enough to run the application.
Full unicode support.
Be able to manipulate OS threads (create them, run multiple tasks in parallel on multi-core CPUs, etc).
Be reasonably fast (Python level performance and better).
To have some kind of standard library that does low-level, mundane tasks.
Not very niche and have some community behind it to be able to ask questions.
My 'nice to have' requirements are:
Language should be functional
It should have good string manipulation capabilities (not necessarily regex)
Not extremely hard to learn
I'm thinking about Haskell now but keeping in mind OCaml as well.
Please advice if my choice is correct.
This might be a silly question, but still I am going ahead and asking it.
Nowadays I see new dynamic languages like Groovy being developed for the JVM, and languages like Ruby gaining prominence.
Each of these seems to be solving different shortcomings in the existing languages.
Is there any one or set of problems that are not addressed by any of the current languages?
Seeing the amount of softwares developed (and still being developed) in C and considering the fact that C currently tops the TIOBE chart, I have this one question for you all: Do we really need high level languages like C# or F# or Ruby? Don't you think these so-called high level languages are actually spoiling programmers and resulting in suboptimal and non-efficient softwares?
i have known that winpcap library enabled a person to obtain advanced information about installed devices...
given all the networking devices found in the computer, how will i know which one of this has an internet connection?!
thanks:)
I am using colorscheme desert256.
It is quite nice except for an annoying detail:
I cannot really tell where the cursor is sometimes.
How can I change just the cursor style, (say make it red)?
Thanks
if I have this snippet of the code
A a1(i);
A a2 = a1;
A *pa1 = new A(a2);
can somebody please explain what exactly the last line does, it makes copy of the a2 and pointer for this new object is pa1 or it just creates pointer for a2, thanks in advance
Hello
I am trying to make a list of things which can be difficult/surprising to someone who is changing language from PHP to Python.
so far i have rather short list:
forget require / include, learn import (this was most difficult to me - to understand package - module - class - object hierarchy and its mapping to filesystem)
you can't just upload file on server to have webpage (-mod_python, wsgi etc)
learn the python way for use variable class names (new $class() vs import + getattr)
/ operator in python 2.x and all float-related horrors
those were difficult to me, it takes few days before mind adapts a new paradigm
after i found that there is few other areas which could be challenging for someone with (too) many years of php:
everything is an object
you have to live with exceptions
array vs list, set, dictionary, tuple ...
learn (effective) list comprehensions
learn generators
any other ideas / personal experiences ?
The following code works fine
#include <functional>
using namespace std;
using namespace std::placeholders;
class A
{
int operator()( int i, int j ) { return i - j; }
};
A a;
auto aBind = bind( &A::operator(), ref(a), _2, _1 );
This does not
#include <functional>
using namespace std;
using namespace std::placeholders;
class A
{
int operator()( int i, int j ) { return i - j; }
int operator()( int i ) { return -i; }
};
A a;
auto aBind = bind( &A::operator(), ref(a), _2, _1 );
I have tried playing around with the syntax to try and explicitly resolve which function I want in the code that does not work without luck so far. How do I write the bind line in order to choose the call that takes the two integer arguments?
Hi,
I'm writing a kernel module that reads from a /proc file.
When someone writes into the /proc file the reader will read it, but if it reads again while there is no "new" write, it should be blocked.
In order to remember if we already read, i need to keep a map of the latest buffer that process read.
To avoid that, I was told that there might be some redundant field inside the current- (task_struct struct) that i can use to my benefits in order to save some states on the current process.
How can I find such fields ? and how can i avoid them being overwritten ?
I read somewhere that i can use the offset field inside the struct in order to save my information there and i need to block lseek operations so that field will stay untouched.
How can I do so ? and where is that offset field, i can't find it inside the task_Struct.
Thanks
and I need to save for each process some information in order to map it against other information.
I can write a ma
I know the question has no practical value, but it is interesting why in some languages semicolons and {} blocks are removed although their predecessor have them.
Actually it makes me nervous to write a code in Python as there are no ";" and {}.
Also in new language Google-GO semicolons are also missing although it says that lexer uses a rule to insert semicolons automatically as it scans.
So is there any secret :) reason for this.
I'm writing a small server-like program in C for Windows (using MinGW/GCC, testing on Windows 7) which is eventually supposed to run as a service with the LocalSystem account. I am creating a socket, and using Windows Sockets bind(), listen() and accept() to listen for incoming connections. If I run the application from the command line (i.e. not as a service, but as a normal user), I have no problems connecting to it from external IPs. However, if I run the program as a service with the LocalSystem account, I can only connect to the service from my own PC, either with 127.0.0.1 or my local address, 192.168.1.80 (I'm behind a router in a small local network). Neither external IPs nor other PCs in the same local network, using my local address, can connect now, even though there were no problems without running as a service.
Now, I've heard that networking is handled differently or even not accessible (?) when running as LocalSystem or LocalService or that services cannot access both the desktop and the network (note: my service is not interactive) at the same time due to security considerations. Essentially, I need to find out what's going wrong/how to listen for connections in a service. Is running as NetworkService the same as running as LocalSystem, but with network access? Surely there must be servers that can run as background services, so how do they do it?
Hello,
I would like to learn how to develop games. What language is best for that? Java? C#? Ruby? ActionScript?
I would like to develop web based games and possibly mobile games, not desktop games.
Every time i pass some parameters to a JavasScript or jQuery functon, i use some random letters. What are the correct letters for the corresponding variable types?
function(o){} for example is for a object. But what are the other letters? Do someone have a list of those?
Hi,
what the syntax is in Action Mailer Basics rails guide ?
class UserMailer < ActionMailer::Base
def welcome_email(user)
recipients user.email
from "My Awesome Site Notifications <[email protected]>"
subject "Welcome to My Awesome Site"
sent_on Time.now
body {:user => user, :url => "http://example.com/login"}
end
end
How should i understand the construction, like
from "Some text for this field"
Is it an assignment the value to a variable, called "from" ?