Search Results

Search found 20401 results on 817 pages for 'null coalescing operator'.

Page 18/817 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • how to refer to the current struct in an overloaded operator?

    - by genesys
    Hi! I have a struct for which i want to define a relative order by defining < , , <= and = operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger. I defined the first operator like this: struct MyStruct{ ... ... bool operator < (const MyStruct &b) const {return (somefancycomputation);} }; now i'd like to define the other operators based on this operator, such that <= will return the same as < and the other two will simply return the oposite. so for example for the operator i'd like to write something like bool operator > (const MyStruct &b) const {return !(self<b);} but i don't know how to refere to this 'self' since i can refere only to the fields inside the current struct. whole is in C++ hope my question was understandable :) thank you for the help!

    Read the article

  • Defining < for STL sort algorithm - operator overload, functor or standalone function?

    - by Andy
    I have a stl::list containing Widget class objects. They need to be sorted according to two members in the Widget class. For the sorting to work, I need to define a less-than comparator comparing two Widget objects. There seems to be a myriad of ways to do it. From what I can gather, one can either: a. Define a comparison operator overload in the class: bool Widget::operator< (const Widget &rhs) const b. Define a standalone function taking two Widgets: bool operator<(const Widget& lhs, const Widget& rhs); And then make the Widget class a friend of it: class Widget { // Various class definitions ... friend bool operator<(const Widget& lhs, const Widget& rhs); }; c. Define a functor and then include it as a parameter when calling the sort function: class Widget_Less : public binary_function<Widget, Widget, bool> { bool operator()(const Widget &lhs, const Widget& rhs) const; }; Does anybody know which method is better? In particular I am interested to know if I should do 1 or 2. I searched the book Effective STL by Scott Meyer but unfortunately it does not have anything to say about this. Thank you for your reply.

    Read the article

  • [C++] Can all/any struct assignment operator be Overloaded? (and specifically struct tm = sql::Resu

    - by Luke Mcneice
    Hi all, Generally, i was wondering if there was any exceptions of types that cant have thier assignment operator overloaded. Specifically, I'm wanting to overload the assignment operator of a tm struct, (time.h) so i can assign a sql::ResultSet to it. I have already have the conversion logic: sscanf(sqlresult->getString("StoredAt").c_str(),"%d-%d-%d %d:%d:%d",&TempTimeStruct->tm_year,&TempTimeStruct->tm_mon,&TempTimeStruct->tm_mday,&TempTimeStruct->tm_hour,&TempTimeStruct->tm_min,&TempTimeStruct->tm_sec); //populating the struct I tried the overload with this: tm& tm::operator=(sql::ResultSet & results) { //CODE return *this; } however VS08 reports: error C2511: 'tm &tm::operator =(sql::ResultSet &)' : overloaded member function not found in 'tm'

    Read the article

  • What is the purpose of Java's unary plus operator?

    - by Syntactic
    Java's unary plus operator appears to have come over from C, via C++. As near as I can tell, it has the following effects: promotes its operand to int, if it's not already an int or wider unboxes its operand, if it's a wrapper object complicates slightly the parsing of evil expressions containing large numbers of consecutive plus signs It seems to me that there are better (or, at least, clearer) ways to do all of these things. In this SO question, concerning the counterpart operator in C#, someone said that "It's there to be overloaded if you feel the need." But in Java, one cannot overload any operator. So does this operator exist in Java just because it existed in C++?

    Read the article

  • In what situation should the built-in 'operator' module be used in python?

    - by apphacker
    I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a set of functions implemented in C corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. The function names are those used for special class methods; variants without leading and trailing __ are also provided for convenience. I'm not sure I understand the benefit or purpose of this module.

    Read the article

  • How to index a date column with null values?

    - by Heinz Z.
    How should I index a date column when some rows has null values? We have to select rows between a date range and rows with null dates. We use Oracle 9.2 and higher. Options I found Using a bitmap index on the date column Using an index on date column and an index on a state field which value is 1 when the date is null Using an index on date column and an other granted not null column My thoughts to the options are: to 1: the table have to many different values to use an bitmap index to 2: I have to add an field only for this purpose and to change the query when I want to retrieve the null date rows to 3: locks tricky to add an field to an index which is not really needed What is the best practice for this case? Thanks in advance Some infos I have read: Oracle Date Index When does Oracle index null column values?

    Read the article

  • How to get the first non-null value in Java?

    - by froadie
    Is there a Java equivalent of SQL's COALESCE function? That is, is there any way to return the first non-null value of several variables? e.g. Double a = null; Double b = 4.4; Double c = null; I want to somehow have a statement that will return the first non-null value of a, b, and c - in this case, it would return b, or 4.4. (Something like the sql method - return COALESCE(a,b,c)). I know that I can do it explicitly with something like: return a != null ? a : (b != null ? b : c) But I wondered if there was any built-in, accepted function to accomplish this.

    Read the article

  • C# Extend array type to overload operators

    - by Episodex
    I'd like to create my own class extending array of ints. Is that possible? What I need is array of ints that can be added by "+" operator to another array (each element added to each), and compared by "==", so it could (hopefully) be used as a key in dictionary. The thing is I don't want to implement whole IList interface to my new class, but only add those two operators to existing array class. I'm trying to do something like this: class MyArray : Array<int> But it's not working that way obviously ;). Sorry if I'm unclear but I'm searching solution for hours now... UPDATE: I tried something like this: class Zmienne : IEquatable<Zmienne> { public int[] x; public Zmienne(int ilosc) { x = new int[ilosc]; } public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return false; } return base.Equals((Zmienne)obj); } public bool Equals(Zmienne drugie) { if (x.Length != drugie.x.Length) return false; else { for (int i = 0; i < x.Length; i++) { if (x[i] != drugie.x[i]) return false; } } return true; } public override int GetHashCode() { int hash = x[0].GetHashCode(); for (int i = 1; i < x.Length; i++) hash = hash ^ x[i].GetHashCode(); return hash; } } Then use it like this: Zmienne tab1 = new Zmienne(2); Zmienne tab2 = new Zmienne(2); tab1.x[0] = 1; tab1.x[1] = 1; tab2.x[0] = 1; tab2.x[1] = 1; if (tab1 == tab2) Console.WriteLine("Works!"); And no effect. I'm not good with interfaces and overriding methods unfortunately :(. As for reason I'm trying to do it. I have some equations like: x1 + x2 = 0.45 x1 + x4 = 0.2 x2 + x4 = 0.11 There are a lot more of them, and I need to for example add first equation to second and search all others to find out if there is any that matches the combination of x'es resulting in that adding. Maybe I'm going in totally wrong direction?

    Read the article

  • Why is Perl's smart-match operator considered broken?

    - by Sean McMillan
    I've seen a number of comments across the web Perl's smart-match operator is broken. I know it originally was part of Perl 6, then was implemented in Perl 5.10 off of an old version of the spec, and was then corrected in 5.10.1 to match the current Perl 6 spec. Is the problem fixed in 5.10.1+, or are there other problems with the smart-match operator that make it troublesome in practice? What are the problems? Is there a yet-more-updated version (Perl 6, perhaps) that fixes the problems?

    Read the article

  • Undocumented Gmail Search Operator Ferrets Out Large Email Attachments

    - by Jason Fitzpatrick
    If you’re looking for a way to quickly find large email attachments in your Gmail account, this undocumented search operator makes it simple to zero in on the hulking attachments hiding out in your inbox. To use the search operator simply plug in “size:” and some value to narrow your search to only emails that size or larger. In the screenshot above we searched for “size:20000000″ to search for files roughly 20MB or larger (if you want to be extremely precise, a true 20MB search would be “size:20971520″). If you’re looking to clean up your Gmail account this is a nearly zero-effort way to find the biggest space hogs–in our case, we found an email packed with massive PDF files from a 5 year old project that we were more than happy to purge. Finding Large Attachments in Google Mail/Gmail [via gHacks] 6 Ways Windows 8 Is More Secure Than Windows 7 HTG Explains: Why It’s Good That Your Computer’s RAM Is Full 10 Awesome Improvements For Desktop Users in Windows 8

    Read the article

  • Why would one overload the && and & operator?

    - by acidzombie24
    The same question goes for | and ||. Why would one overload or 'use' the & and && operator? The only use i thought of are Bitwise Ands for int base types (but not float/decimals) using & logical short circuit for bools/functions that return bool. Using the && operator usually. I cant think of any classes that use those operators. Absolutely none. I know a class might support + (and not '-') which combine two strings together. I seen an object such as datetime overload '-' so two dates can be subtracted to make a timespan (obviously you cant add two dates) but i never seen &, &&, | and || used. Does anyone know of a use? In any language?

    Read the article

  • Find all those columns which have only null values, in a MySQL table

    - by Robin v. G.
    The situation is as follows: I have a substantial number of tables, with each a substantial number of columns. I need to deal with this old and to-be-deprecated database for a new system, and I'm looking for a way to eliminate all columns that have - apparently - never been in use. I wanna do this by filtering out all columns that have a value on any given row, leaving me with a set of columns where the value is NULL in all rows. Of course I could manually sort every column descending, but that'd take too long as I'm dealing with loads of tables and columns. I estimate it to be 400 tables with up to 50 (!) columns per table. Is there any way I can get this information from the information_schema? EDIT: Here's an example: column_a column_b column_c column_d NULL NULL NULL 1 NULL 1 NULL 1 NULL 1 NULL NULL NULL NULL NULL NULL The output should be 'column_a' and 'column_c', for being the only columns without any filled in values.

    Read the article

  • Template inheritence c++

    - by Chris Condy
    I have made a template singleton class, I have also made a data structure that is templated. My question is; how do I make my templated data structure inherit from a singleton so you can only have one float type of this structure? I have tested both seperate and have found no problems. Code provided under... (That is the problem) template <class Type> class AbstractRManagers : public Singleton<AbstractRManagers<Type> > The problem is the code above doesn't work I get alot of errors. I cant get it to no matter what I do template a templated singleton class... I was asking for maybe advice or maybe if the code above is incorrect guidence? #ifndef SINGLETON_H #define SINGLETON_H template <class Type> class Singleton { public: virtual ~Singleton(); Singleton(); static Type* m_instance; }; template <class Type> Type* Singleton<Type>::m_instance = 0; #include "Singleton.cpp" #endif #ifndef SINGLETON_CPP #define SINGLETON_CPP #include "Singleton.h" template <class Type> Singleton<Type>::Singleton() { } template <class Type> Singleton<Type>::~Singleton() { } template <class Type> Type* Singleton<Type>::getInstance() { if(m_instance==nullptr) { m_instance = new Type; } return m_instance; } #endif #ifndef ABSTRACTRMANAGERS_H #define ABSTRACTRMANAGERS_H #include <vector> #include <map> #include <stack> #include "Singleton.h" template <class Type> class AbstractRManagers : public Singleton<AbstractRManagers<Type> > { public: virtual ~AbstractRManagers(); int insert(Type* type, std::string name); Type* remove(int i); Type* remove(std::string name); Type* get(int i); Type* getS(std::string name); int get(std::string name); int get(Type* i); bool check(std::string name); int resourceSize(); protected: private: std::vector<Type*> m_resources; std::map<std::string,int> m_map; std::stack<int> m_freePos; }; #include "AbstractRManagers.cpp" #endif #ifndef ABSTRACTRMANAGERS_CPP #define ABSTRACTRMANAGERS_CPP #include "AbstractRManagers.h" template <class Type> int AbstractRManagers<Type>::insert(Type* type, std::string name) { int i=0; if(!check(name)) { if(m_freePos.empty()) { m_resources.push_back(type); i = m_resources.size()-1; m_map[name] = i; } else { i = m_freePos.top(); m_freePos.pop(); m_resources[i] = type; m_map[name] = i; } } else i = -1; return i; } template <class Type> int AbstractRManagers<Type>::resourceSize() { return m_resources.size(); } template <class Type> bool AbstractRManagers<Type>::check(std::string name) { std::map<std::string,int>::iterator it; it = m_map.find(name); if(it==m_map.end()) return false; return true; } template <class Type> Type* AbstractRManagers<Type>::remove(std::string name) { Type* temp = m_resources[m_map[name]]; if(temp!=NULL) { std::map<std::string,int>::iterator it; it = m_map[name]; m_resources[m_map[name]] = NULL; m_freePos.push(m_map[name]); delete (*it).second; delete (*it).first; return temp; } return NULL; } template <class Type> Type* AbstractRManagers<Type>::remove(int i) { if((i < m_resources.size())&&(i > 0)) { Type* temp = m_resources[i]; m_resources[i] = NULL; m_freePos.push(i); std::map<std::string,int>::iterator it; for(it=m_map.begin();it!=m_map.end();it++) { if((*it).second == i) { delete (*it).second; delete (*it).first; return temp; } } return temp; } return NULL; } template <class Type> int AbstractRManagers<Type>::get(Type* i) { for(int i2=0;i2<m_resources.size();i2++) { if(i == m_resources[i2]) { return i2; } } return -1; } template <class Type> Type* AbstractRManagers<Type>::get(int i) { if((i < m_resources.size())&&(i >= 0)) { return m_resources[i]; } return NULL; } template <class Type> Type* AbstractRManagers<Type>::getS(std::string name) { return m_resources[m_map[name]]; } template <class Type> int AbstractRManagers<Type>::get(std::string name) { return m_map[name]; } template <class Type> AbstractRManagers<Type>::~AbstractRManagers() { } #endif #include "AbstractRManagers.h" struct b { float x; }; int main() { b* a = new b(); AbstractRManagers<b>::getInstance()->insert(a,"a"); return 0; } This program produces next errors when compiled : 1> main.cpp 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\stack(166) : see declaration of 'std::operator <' 1> c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(124) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const' 1> with 1> [ 1> _Ty=std::string 1> ] 1> c:\program files\microsoft visual studio 10.0\vc\include\map(71) : see reference to class template instantiation 'std::less<_Ty>' being compiled 1> with 1> [ 1> _Ty=std::string 1> ] 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(451) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled 1> with 1> [ 1> _Kty=std::string, 1> _Ty=int, 1> _Pr=std::less<std::string>, 1> _Alloc=std::allocator<std::pair<const std::string,int>>, 1> _Mfl=false 1> ] 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(520) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled 1> with 1> [ 1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false> 1> ] 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(659) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled 1> with 1> [ 1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false> 1> ] 1> c:\program files\microsoft visual studio 10.0\vc\include\map(81) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled 1> with 1> [ 1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false> 1> ] 1> c:\users\chris\desktop\311\ideas\idea1\idea1\abstractrmanagers.h(28) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled 1> with 1> [ 1> _Kty=std::string, 1> _Ty=int 1> ] 1> c:\users\chris\desktop\311\ideas\idea1\idea1\abstractrmanagers.h(30) : see reference to class template instantiation 'AbstractRManagers<Type>' being compiled 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\stack(166) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::stack<_Ty,_Container> &,const std::stack<_Ty,_Container> &)' : could not deduce template argument for 'const std::stack<_Ty,_Container> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\stack(166) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\deque(1725) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\deque(1725) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\deque(1725) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(1885) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(1885) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(1885) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\vector(1502) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\vector(1502) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\vector(1502) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\memory(2582) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\memory(2582) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\memory(2582) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1356) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1356) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1356) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1179) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1179) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\xutility(1179) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\utility(318) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\utility(318) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string' 1> c:\program files\microsoft visual studio 10.0\vc\include\utility(318) : see declaration of 'std::operator <' 1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Read the article

  • What's the Matlab equivalent of NULL, when it's calling COM/ActiveX methods?

    - by David M
    Hi, I maintain a program which can be automated via COM. Generally customers use VBS to do their scripting, but we have a couple of customers who use Matlab's ActiveX support and are having trouble calling COM object methods with a NULL parameter. They've asked how they do this in Matlab - and I've been scouring Mathworks' COM/ActiveX documentation for a day or so now and can't figure it out. Their example code might look something like this: function do_something() OurAppInstance = actxserver('Foo.Application'); OurAppInstance.Method('Hello', NULL) end where NULL is where in another language, we'd write NULL or nil or Nothing, or, of course, pass in an object. The problem is this is optional (and these are implemented as optional parameters in most, but not all, cases) - these methods expect to get NULL quite often. They tell me they've tried [] (which from my reading seemed the most likely) as well as '', Nothing, 'Nothing', None, Null, and 0. I have no idea how many of those are even valid Matlab keywords - certainly none work in this case. Can anyone help? What's Matlab's syntax for a null pointer / object for use as a COM method parameter? Update: Thanks for all the replies so far! Unfortunately, none of the answers seem to work, not even libpointer. The error is the same in all cases: Error: Type mismatch, argument 2 This parameter in the COM type library is described in RIDL as: HRESULT _stdcall OurMethod([in] BSTR strParamOne, [in, optional] OurCoClass* oParamTwo, [out, retval] VARIANT_BOOL* bResult); The coclass in question implements a single interface descending from IDispatch.

    Read the article

  • Why can one null return be tested but another throws an exception?

    - by mickey
    I want to test if an xml attribute is present. Given this: XmlAttributeCollection PG_attrColl = SomeNodeorAnother.Attributes; This first test works: if (null != PG_attrColl["SomeAttribute"]) "GetNamedItem" is supposed to return null, but the following test throws an exception complaining about the null it returns. if (null != PG_attrColl.GetNamedItem("SomeAttribute").Value;) Why the difference? Just curious.

    Read the article

  • Best way to check for null values in Java?

    - by Arty-fishL
    I need to check whether the function of an object returns true or false in Java, but that object may be null, so obviously then the function would throw a NullPointerException. This means I need to check if the object is null before checking the value of the function. What is the best way to go about this? I've listed some methods I considered, I just want to know the most sensible one, the one that is best programming practice for Java (opinion?). // method 1 if (foo != null) { if (foo.bar()) { etc... } } // method 2 if (foo != null ? foo.bar() : false) { etc... } // method 3 try { if (foo.bar()) { etc... } } catch (NullPointerException e) { } // method 4 // would this work all the time, would it still call foo.bar()? if (foo != null && foo.bar()) { etc... }

    Read the article

  • How to list all duplicated rows which may include NULL columns?

    - by Yousui
    Hi guys, I have a problem of listing duplicated rows that include NULL columns. Lemme show my problem first. USE [tempdb]; GO IF OBJECT_ID(N'dbo.t') IS NOT NULL BEGIN DROP TABLE dbo.t END GO CREATE TABLE dbo.t ( a NVARCHAR(8), b NVARCHAR(8) ); GO INSERT t VALUES ('a', 'b'); INSERT t VALUES ('a', 'b'); INSERT t VALUES ('a', 'b'); INSERT t VALUES ('c', 'd'); INSERT t VALUES ('c', 'd'); INSERT t VALUES ('c', 'd'); INSERT t VALUES ('c', 'd'); INSERT t VALUES ('e', NULL); INSERT t VALUES (NULL, NULL); INSERT t VALUES (NULL, NULL); INSERT t VALUES (NULL, NULL); INSERT t VALUES (NULL, NULL); GO Now I want to show all rows that have other rows duplicated with them, I use the following query. SELECT a, b FROM dbo.t GROUP BY a, b HAVING count(*) > 1 which will give us the result: a b -------- -------- NULL NULL a b c d Now if I want to list all rows that make contribution to duplication, I use this query: WITH duplicate (a, b) AS ( SELECT a, b FROM dbo.t GROUP BY a, b HAVING count(*) > 1 ) SELECT dbo.t.a, dbo.t.b FROM dbo.t INNER JOIN duplicate ON (dbo.t.a = duplicate.a AND dbo.t.b = duplicate.b) Which will give me the result: a b -------- -------- a b a b a b c d c d c d c d As you can see, all rows include NULLs are filtered. The reason I thought is that I use equal sign to test the condition(dbo.t.a = duplicate.a AND dbo.t.b = duplicate.b), and NULLs cannot be compared use equal sign. So, in order to include rows that include NULLs in it in the last result, I have change the aforementioned query to WITH duplicate (a, b) AS ( SELECT a, b FROM dbo.t GROUP BY a, b HAVING count(*) > 1 ) SELECT dbo.t.a, dbo.t.b FROM dbo.t INNER JOIN duplicate ON (dbo.t.a = duplicate.a AND dbo.t.b = duplicate.b) OR (dbo.t.a IS NULL AND duplicate.a IS NULL AND dbo.t.b = duplicate.b) OR (dbo.t.b IS NULL AND duplicate.b IS NULL AND dbo.t.a = duplicate.a) OR (dbo.t.a IS NULL AND duplicate.a IS NULL AND dbo.t.b IS NULL AND duplicate.b IS NULL) And this query will give me the answer as I wanted: a b -------- -------- NULL NULL NULL NULL NULL NULL NULL NULL a b a b a b c d c d c d c d Now my question is, as you can see, this query just include two columns, in order to include NULLs in the last result, you have to use many condition testing statements in the query. As the column number increasing, the condition testing statements you need in your query is increasing astonishingly. How can I solve this problem? Great thanks.

    Read the article

  • When I overload the assignment operator for my simple class array, I get the wrong answer I espect

    - by user299648
    //output is "01234 00000" but the output should be or what I want it to be is // "01234 01234" because of the assignment overloaded operator #include <iostream> using namespace std; class IntArray { public: IntArray() : size(10), used(0) { a= new int[10]; } IntArray(int s) : size(s), used(0) { a= new int[s]; } int& operator[]( int index ); IntArray& operator =( const IntArray& rightside ); ~IntArray() { delete [] a; } private: int *a; int size; int used;//for array position }; int main() { IntArray copy; if( 2>1) { IntArray arr(5); for( int k=0; k<5; k++) arr[k]=k; copy = arr; for( int j=0; j<5; j++) cout<<arr[j]; } cout<<" "; for( int j=0; j<5; j++) cout<<copy[j]; return 0; } int& IntArray::operator[]( int index ) { if( index >= size ) cout<<"ilegal index in IntArray"<<endl; return a[index]; } IntArray& IntArray::operator =( const IntArray& rightside ) { if( size != rightside.size )//also checks if on both side same object { delete [] a; a= new int[rightside.size]; } size=rightside.size; used=rightside.used; for( int i = 0; i < used; i++ ) a[i]=rightside.a[i]; return *this; }

    Read the article

  • How to order by column with non-null values first in sql

    - by devlife
    I need to write a sql statement to select all users ordered by lastname, firstname. This is the part I know how to do :) What I don't know how to do is to order by non-null values first. Right now I get this: null, null null, null p1Last, p1First p2Last, p2First etc I need to get: p1Last, p1First p2Last, p2First null, null null, null Any thoughts?

    Read the article

  • Assigning a vector of one type to a vector of another type

    - by deworde
    Hi, I have an "Event" class. Due to the way dates are handled, we need to wrap this class in a "UIEvent" class, which holds the Event, and the date of the Event in another format. What is the best way of allowing conversion from Event to UIEvent and back? I thought overloading the assignment or copy constructor of UIEvent to accept Events (and vice versa)might be best.

    Read the article

  • Problem in Saving Multi Level Models in YII

    - by Waqar
    My Table structure for user and his adress detail is as follows CREATE TABLE tbl_users ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, loginname varchar(128) NOT NULL, enabled enum("True","False"), approved enum("True","False"), password varchar(128) NOT NULL, email varchar(128) NOT NULL, role_id int(20) NOT NULL DEFAULT '2', name varchar(70) NOT NULL, co_type enum("S/O","D/O","W/O") DEFAULT "S/O", co_name varchar(70), gender enum("MALE","FEMALE","OTHER") DEFAULT "MALE", dob date DEFAULT NULL, maritalstatus enum("SINGLE","MARRIED","DIVORCED","WIDOWER") DEFAULT "MARRIED", occupation varchar(100) DEFAULT NULL, occupationtype_id int(20) DEFAULT NULL, occupationindustry_id int(20) DEFAULT NULL, contact_id bigint(20) unsigned DEFAULT NULL, signupreason varchar(500), PRIMARY KEY (id), UNIQUE KEY loginname (loginname), UNIQUE KEY email (email), FOREIGN KEY (role_id) REFERENCES tbl_roles (id), FOREIGN KEY (occupationtype_id) REFERENCES tbl_occupationtypes (id), FOREIGN KEY (occupationindustry_id) REFERENCES tbl_occupationindustries (id), FOREIGN KEY (contact_id) REFERENCES tbl_contacts (id) ) ENGINE=InnoDB; CREATE TABLE tbl_contacts ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, contact_type enum("cres","pres","coff"), address varchar(300) DEFAULT NULL, landmark varchar(100) DEFAULT NULL, district_id int(11) DEFAULT NULL, city_id int(20) DEFAULT NULL, state_id int(20) DEFAULT NULL, pin_id bigint(20) unsigned DEFAULT NULL, area_id bigint(20) unsigned DEFAULT NULL, po_id bigint(20) unsigned DEFAULT NULL, phone1 varchar(20) DEFAULT NULL, phone2 varchar(20) DEFAULT NULL, mobile1 varchar(20) DEFAULT NULL, mobile2 varchar(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (district_id) REFERENCES tbl_districts (id), FOREIGN KEY (city_id) REFERENCES tbl_cities (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; CREATE TABLE tbl_states ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB; CREATE TABLE tbl_districts ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, state_id int(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; CREATE TABLE tbl_cities ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, district_id int(20) DEFAULT NULL, state_id int(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (district_id) REFERENCES tbl_districts (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; The relationship is as follows User has multiple contacts i.e Permanent Address, Current Address, Office Address. Each Contact has state and City. User-Contact-state like this How to save models of this structure in one go. Please provide a reply ASAP

    Read the article

  • executing null values records

    - by jjj
    i am trying to execute the records that have TotalTime null value from the table NewTimeAttendance...TotalTime datatype nchar(10) select * from newtimeattendance where TotalTime = 'NULL' ....nothing select * from newtimeattendance where TotalTime = 'null' ....nothing select * from newtimeattendance where TotalTime = 'Null' ....nothing select * from newtimeattendance where TotalTime = null ....nothing select * from newtimeattendance where TotalTime = Null ....nothing select * from newtimeattendance where TotalTime = NULL ....nothing when i select the whole table i can see that there is some NULL TotalTime values..!! it is small select statment ..why doesn't it work ? is there a way (special way ) to execute the 'NULL' with nchar type ?! thanks in advance

    Read the article

  • == and === operators in php

    - by Lizard
    Lets say I have a variable that will always be a string. Now take the code below: if($myVar === "teststring") Note $myVar will always be a string, so my questions is Which is quicker/best, using === (Indentity) or the == (Equality)?

    Read the article

  • MiniMax function throws null pointer exception

    - by Sven
    I'm working on a school project, I have to build a tic tac toe game with the AI based on the MiniMax algorithm. The two player mode works like it should. I followed the code example on http://ethangunderson.com/blog/minimax-algorithm-in-c/. The only thing is that I get a NullPointer Exception when I run the code. And I can't wrap my finger around it. I placed a comment in the code where the exception is thrown. The recursive call is returning a null pointer, what is very strange because it can't.. When I place a breakpoint on the null return with the help of a if statement, then I see that there ARE still 2 to 3 empty places.. I probably overlooking something. Hope someone can tell me what I'm doing wrong. Here is the MiniMax code (the tic tac toe code is not important): /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package MiniMax; import Game.Block; import Game.Board; import java.util.ArrayList; public class MiniMax { public static Place getBestMove(Board gameBoard, Block.TYPE player) { Place bestPlace = null; ArrayList<Place> emptyPlaces = gameBoard.getEmptyPlaces(); Board newBoard; //loop trough all the empty places for(Place emptyPlace : emptyPlaces) { newBoard = gameBoard.clone(); newBoard.setBlock(emptyPlace.getRow(), emptyPlace.getCell(), player); //no game won and still room to move if(newBoard.getWinner() == Block.TYPE.NONE && newBoard.getEmptyPlaces().size() > 0) { //is an node (has children) Place tempPlace = getBestMove(newBoard, invertPlayer(player)); //ERROR is thrown here! tempPlace is null. emptyPlace.setScore(tempPlace.getScore()); } else { //is an leaf if(newBoard.getWinner() == Block.TYPE.NONE) { emptyPlace.setScore(0); } else if(newBoard.getWinner() == Block.TYPE.X) { emptyPlace.setScore(-1); } else if(newBoard.getWinner() == Block.TYPE.O) { emptyPlace.setScore(1); } //if this move is better then our prev move, take it! if((bestPlace == null) || (player == Block.TYPE.X && emptyPlace.getScore() < bestPlace.getScore()) || (player == Block.TYPE.O && emptyPlace.getScore() > bestPlace.getScore())) { bestPlace = emptyPlace; } } } //This should never be null, but it does.. return bestPlace; } private static Block.TYPE invertPlayer(Block.TYPE player) { if(player == Block.TYPE.X) { return Block.TYPE.O; } return Block.TYPE.X; } }

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >