void BuiltInOperator::fetchExtraOverloads( MemberPointerType* a_pMemberPointerType, vector<overload>& a_Overloads ) const
{
    Type* pBoolType = typeOf<bool>();
    switch(m_eOperator)
    {
        /// standard 13.6.16
        /// ------------------------
        /// bool operator==(T , T );
    case e_Operator_Equal:
        a_Overloads.push_back(overload(pBoolType, a_pMemberPointerType, a_pMemberPointerType, operation_delegate_t(a_pMemberPointerType, &MemberPointerType::equal)));
        break;

        /// bool operator!=(T , T );
    case e_Operator_NotEqual:
        a_Overloads.push_back(overload(pBoolType, a_pMemberPointerType, a_pMemberPointerType, operation_delegate_t(a_pMemberPointerType, &MemberPointerType::notEqual)));
        break;

        /// standard 13.6.20
        /// ------------------------
        /// VQ T & operator=(VQ T &, T );
    case e_Operator_Assignment:
        a_Overloads.push_back(overload(a_pMemberPointerType->lvalueReferenceType(), a_pMemberPointerType->lvalueReferenceType(), a_pMemberPointerType, operation_delegate_t(a_pMemberPointerType, &MemberPointerType::assignment)));
        a_Overloads.push_back(overload(a_pMemberPointerType->volatileType()->lvalueReferenceType(), a_pMemberPointerType->volatileType()->lvalueReferenceType(), a_pMemberPointerType, operation_delegate_t(a_pMemberPointerType, &MemberPointerType::assignment)));
        break;
    }
}
double SamplingThread::value( double timeStamp )
{
    double v;
    traway++;
    emit overload(false); // turns of overload led (in case it was on)
    if(buffer.count("\n")>10) {
        buffer=buffer.mid(buffer.lastIndexOf("\n")+1,-1);
        qDebug()<<traway << "overrun\n";
        traway=0;
        emit overload(true); // makes the red "led" flash.
    }
    QByteArray inpt;
    int a = port->bytesAvailable();
    inpt.resize(a);
    port->read(inpt.data(), inpt.size());
    QString strng=buffer+QString::fromAscii(inpt);
    int j=strng.indexOf("\n");
    if(j==1) {
        qDebug() << "-"<<strng <<"-";
        strng=strng.right(1);
    }
    if(j>-1) {
        QString s=strng.left(j-1);
        v=s.toFloat();
        // Saves for next time what has so far not been read:
        buffer=strng.mid(j+1,-1);
        return v*d_amplitude/5;
    }

}
示例#3
0
  ExecStatus
  ManProp<ManTask,Cap,PL>::propagate(Space& home, const ModEventDelta& med) {
    // Only bounds changes?
    if (IntView::me(med) != ME_INT_DOM)
      GECODE_ES_CHECK(overload(home,c.max(),t));

    if (PL::advanced)
      GECODE_ES_CHECK(edgefinding(home,c.max(),t));

    if (PL::basic)
      GECODE_ES_CHECK(timetabling(home,*this,c,t));

    if (Cap::varderived() && c.assigned() && (c.val() == 1)) {
      // Check that tasks do not overload resource
      for (int i=t.size(); i--; )
        if (t[i].c() > 1)
          return ES_FAILED;
      // Rewrite to unary resource constraint
      TaskArray<typename TaskTraits<ManTask>::UnaryTask> ut(home,t.size());
      for (int i=t.size(); i--;)
        ut[i]=t[i];
      GECODE_REWRITE(*this,
        (Unary::ManProp<typename TaskTraits<ManTask>::UnaryTask,PL>
          ::post(home(*this),ut)));
    }

    if (!PL::basic && c.assigned())
      GECODE_ES_CHECK(subsumed(home,*this,c.val(),t));

    return ES_NOFIX;
  }
示例#4
0
 ExecStatus 
 ManProp<ManTask,Cap>::propagate(Space& home, const ModEventDelta& med) {
   // Only bounds changes?
   if (Int::IntView::me(med) != Int::ME_INT_DOM)
     GECODE_ES_CHECK(overload(home,c.max(),t));
   GECODE_ES_CHECK(edgefinding(home,c.max(),t));
   bool subsumed;
   ExecStatus es = basic(home,subsumed,c,t);
   GECODE_ES_CHECK(es);
   if (subsumed)
     return home.ES_SUBSUMED(*this);
   if (Cap::varderived() && c.assigned() && c.val()==1) {
     // Check that tasks do not overload resource
     for (int i=t.size(); i--; )
       if (t[i].c() > 1)
         return ES_FAILED;
     // Rewrite to unary resource constraint
     TaskArray<typename TaskTraits<ManTask>::UnaryTask> ut(home,t.size());
     for (int i=t.size(); i--;)
       ut[i]=t[i];
     GECODE_REWRITE(*this,
       (Unary::ManProp<typename TaskTraits<ManTask>::UnaryTask>
         ::post(home(*this),ut)));
   } else {
     return es;
   }
 }
void BuiltInOperator::fetchExtraOverloads( ReferenceType* a_pReferenceType, vector<overload>& a_Overloads ) const
{
    if(m_eOperator == e_Operator_Address)
    {
        a_Overloads.push_back(overload(a_pReferenceType->getReferencedType()->pointerType(), a_pReferenceType, nullptr, operation_delegate_t(a_pReferenceType, &ReferenceType::address)));
    }
    else fetchExtraOverloads(a_pReferenceType->removeReference(), a_Overloads);
}
示例#6
0
 ExecStatus 
 ManProp<ManTask>::propagate(Space& home, const ModEventDelta&) {
   GECODE_ES_CHECK(overload(home,t));
   GECODE_ES_CHECK(detectable(home,t));
   GECODE_ES_CHECK(notfirstnotlast(home,t));
   GECODE_ES_CHECK(edgefinding(home,t));
   GECODE_ES_CHECK(subsumed(home,*this,t));
   return ES_NOFIX;
 }
示例#7
0
 UserdataMetatable &addPropertyAny(const char *name, GetterType getter,
                                   SetterType setter) {
   if (has_key(name)) {
     throw KaguyaException(std::string(name) + " is already registered.");
     return *this;
   }
   property_map_[name] = AnyDataPusher(overload(getter, setter));
   return *this;
 }
示例#8
0
 UserdataMetatable &addProperty(const char *name,
                                GetType (class_type::*getter)() const,
                                void (class_type::*setter)(SetType)) {
   if (has_key(name)) {
     throw KaguyaException(std::string(name) + " is already registered.");
     return *this;
   }
   property_map_[name] = AnyDataPusher(overload(getter, setter));
   return *this;
 }
示例#9
0
  UserdataMetatable &addOverloadedFunctions(const char *name, Funcs... f) {
    if (has_key(name)) {
      throw KaguyaException(std::string(name) + " is already registered.");
      return *this;
    }

    member_map_[name] = AnyDataPusher(overload(f...));

    return *this;
  }
示例#10
0
		UserdataMetatable& addOverloadedFunctions(const char* name, Funcs... f)
		{
			if (has_key(name))
			{
				throw KaguyaException("already registered."); 
				return *this;
			}

			member_map_[name] = metatable_detail::makeDataHolder(overload(f...));

			return *this;
		}
示例#11
0
void BuiltInOperator::fetchExtraOverloads( PointerType* a_pPointerType, vector<overload>& a_Overloads ) const
{
    Type* pBoolType = typeOf<bool>();
    Type* pIntType = typeOf<int>();
    Type* ref = a_pPointerType->lvalueReferenceType(); 
    Type* Vref = a_pPointerType->volatileType()->lvalueReferenceType();
    Type* deref = a_pPointerType->removePointer()->lvalueReferenceType();
    switch(m_eOperator)
    {
    /// 13.6.15
    /// ---------------------- 
    /// bool operator<(T , T );
    /// bool operator>(T , T );
    /// bool operator<=(T , T );
    /// bool operator>=(T , T );
    /// bool operator==(T , T );
    /// bool operator!=(T , T );

    case e_Operator_Less:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::less)));
        break;
    case e_Operator_Greater:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::greater)));
        break;
    case e_Operator_LessEqual:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::lessEqual)));
        break;
    case e_Operator_GreaterEqual:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::greaterEqual)));
        break;
    case e_Operator_Equal:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::equal)));
        break;
    case e_Operator_NotEqual:
        a_Overloads.push_back(overload(pBoolType, a_pPointerType, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::notEqual)));
        break;

        /// 13.6.19
        /// T *VQ & operator=(T *VQ &, T *);
    case e_Operator_Assignment:
        a_Overloads.push_back(overload(ref, ref, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::assignment)));
        a_Overloads.push_back(overload(Vref, Vref, a_pPointerType, operation_delegate_t(a_pPointerType, &PointerType::assignment)));
        break;

    }
}
示例#12
0
    static callable make()
    {
      for (const std::pair<std::array<type_id_t, 2>, callable> &pair : F::make_children()) {
        children[pair.first[0]][pair.first[1]] = pair.second;
      }

      return functional::multidispatch(
          ndt::type("(Any, Any) -> Any"),
          [](const ndt::type & DYND_UNUSED(dst_tp), intptr_t DYND_UNUSED(nsrc), const ndt::type * src_tp)->callable & {
            callable &child = overload(src_tp[0], src_tp[1]);
            if (child.is_null()) {
              throw std::runtime_error("no child found");
            }

            return child;
          },
          0);
    }
示例#13
0
void BuiltInOperator::fetchExtraOverloads( Enum* a_pEnum, vector<overload>& a_Overloads ) const
{
    builtin_operation_delegate_selector selector;
    Type* pBoolType = typeOf<bool>();
    /// 13.6.15
    /// bool operator<(T , T );
    /// bool operator>(T , T );
    /// bool operator<=(T , T );
    /// bool operator>=(T , T );
    /// bool operator==(T , T );
    /// bool operator!=(T , T );
    Type* pUnderlyingType = a_pEnum->getIntType();

    switch(m_eOperator)
    {
    case e_Operator_Less:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_Less, pUnderlyingType, pUnderlyingType)));
        break;
    case e_Operator_Greater:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_Greater, pUnderlyingType, pUnderlyingType)));
        break;
    case e_Operator_LessEqual:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_LessEqual, pUnderlyingType, pUnderlyingType)));
        break;
    case e_Operator_GreaterEqual:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_GreaterEqual, pUnderlyingType, pUnderlyingType)));
        break;
    case e_Operator_Equal:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_Equal, pUnderlyingType, pUnderlyingType)));
        break;
    case e_Operator_NotEqual:
        a_Overloads.push_back(overload(pBoolType, a_pEnum, a_pEnum, selector.delegate(e_Operator_NotEqual, pUnderlyingType, pUnderlyingType)));
        break;
        /// 13.6.19
        /// T *VQ & operator=(T *VQ &, T *);
    case e_Operator_Assignment:
        a_Overloads.push_back(overload(a_pEnum->lvalueReferenceType(), a_pEnum->lvalueReferenceType(), a_pEnum, selector.delegate(e_Operator_Assignment, pUnderlyingType, pUnderlyingType)));
        a_Overloads.push_back(overload(a_pEnum->volatileType()->lvalueReferenceType(), a_pEnum->volatileType()->lvalueReferenceType(), a_pEnum, selector.delegate(e_Operator_Assignment, pUnderlyingType, pUnderlyingType)));
        break;
    }
}
示例#14
0
    static callable make()
    {
      children[fixed_string_type_id][fixed_string_type_id] =
          callable::make<total_order_kernel<fixed_string_type_id, fixed_string_type_id>>();
      children[string_type_id][string_type_id] = callable::make<total_order_kernel<string_type_id, string_type_id>>();
      children[int32_type_id][int32_type_id] = callable::make<total_order_kernel<int32_type_id, int32_type_id>>();
      children[bool_type_id][bool_type_id] = callable::make<total_order_kernel<bool_type_id, bool_type_id>>();

      return functional::multidispatch(
          ndt::type("(Any, Any) -> Any"),
          [](const ndt::type & DYND_UNUSED(dst_tp), intptr_t DYND_UNUSED(nsrc), const ndt::type * src_tp)->callable & {
            callable &child = overload(src_tp[0], src_tp[1]);
            if (child.is_null()) {
              throw std::runtime_error("no child found");
            }

            return child;
          },
          0);
    }
示例#15
0
 void overload(const ndt::type &ret_tp, const std::initializer_list<ndt::type> &arg_tp, const callable &value)
 {
   overload(ret_tp, arg_tp.size(), arg_tp.begin(), value);
 }
示例#16
0
文件: main.cpp 项目: CCJY/coliru
	void call_overload()
	{
		overload(T());
	}
示例#17
0
void BuiltInOperator::fetchExtraOverloads( DataPointerType* a_pDataPointerType, vector<overload>& a_Overloads ) const
{
    Type* std_ptrdiff_t = typeOf<std::ptrdiff_t>();
    Type* pBoolType = typeOf<bool>();
    Type* pIntType = typeOf<int>();
    bool is_void = a_pDataPointerType->getPointedType()->removeAllQualifiers() == typeOf<void>();
    Type* ref = a_pDataPointerType->lvalueReferenceType(); 
    Type* Vref = a_pDataPointerType->volatileType()->lvalueReferenceType();
    Type* deref = a_pDataPointerType->removePointer()->lvalueReferenceType();

    switch(m_eOperator)
    {
        /// 13.6.5
        /// T *VQ & operator++(T *VQ &);
        /// T *VQ & operator--(T *VQ &);
        /// T * operator++(T *VQ &, int);
        /// T * operator--(T *VQ &, int);
    case e_Operator_PreIncrement:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::preIncrement)));
            a_Overloads.push_back(overload(Vref, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::preIncrement)));
        }
        break;
    case e_Operator_PreDecrement:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::preDecrement)));
            a_Overloads.push_back(overload(Vref, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::preDecrement)));
        }
        break;
    case e_Operator_PostIncrement:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, a_pDataPointerType, pIntType, operation_delegate_t(a_pDataPointerType, &DataPointerType::postIncrement)));
            a_Overloads.push_back(overload(Vref, a_pDataPointerType, pIntType, operation_delegate_t(a_pDataPointerType, &DataPointerType::postIncrement)));
        }
        break;
    case e_Operator_PostDecrement:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, a_pDataPointerType, pIntType, operation_delegate_t(a_pDataPointerType, &DataPointerType::postDecrement)));
            a_Overloads.push_back(overload(Vref, a_pDataPointerType, pIntType, operation_delegate_t(a_pDataPointerType, &DataPointerType::postDecrement)));
        }
        break;

        /// 13.6.6
        /// T & operator*(T *);
        // 
    case e_Operator_Dereference:
        if(!is_void)
        {
            a_Overloads.push_back(overload(deref, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::dereference)));
        }
        break;

        /// 13.6.8
        /// T * operator+(T *);
        // 
    case e_Operator_Plus:
        a_Overloads.push_back(overload(a_pDataPointerType, a_pDataPointerType, nullptr, operation_delegate_t(a_pDataPointerType, &DataPointerType::plus)));
        break;

        /// 13.6.13
        /// T * operator+(T *, std::ptrdiff_t);
        /// T & operator[](T *, std::ptrdiff_t);
        /// T * operator-(T *, std::ptrdiff_t);
        /// T * operator+(std::ptrdiff_t, T *);
        /// T & operator[](std::ptrdiff_t, T *);

    case e_Operator_Add:
        if(!is_void)
        {
            a_Overloads.push_back(overload(a_pDataPointerType, std_ptrdiff_t, a_pDataPointerType, operation_delegate_t(a_pDataPointerType, &DataPointerType::addRev)));
            a_Overloads.push_back(overload(a_pDataPointerType, a_pDataPointerType, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::add)));
        }
        break;

    case e_Operator_Subtract:
        if(!is_void)
        {
            a_Overloads.push_back(overload(a_pDataPointerType, a_pDataPointerType, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::subtract)));
        }
        /// 13.6.14
        /// std::ptrdiff_t operator-(T , T );
        a_Overloads.push_back(overload(std_ptrdiff_t, a_pDataPointerType, a_pDataPointerType, operation_delegate_t(a_pDataPointerType, &DataPointerType::subtractPointer)));
        break;

    case e_Operator_Bracket:
        if(!is_void)
        {
            a_Overloads.push_back(overload(deref, std_ptrdiff_t, a_pDataPointerType, operation_delegate_t(a_pDataPointerType, &DataPointerType::bracketRev)));
            a_Overloads.push_back(overload(deref, a_pDataPointerType, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::bracket)));
        }
        break;


        /// 13.6.21
        /// T *VQ & operator+=(T *VQ &, std::ptrdiff_t);
        /// T *VQ & operator-=(T *VQ &, std::ptrdiff_t);
    case e_Operator_AssignmentAdd:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, ref, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::assignmentAdd)));
            a_Overloads.push_back(overload(Vref, Vref, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::assignmentAdd)));
        }
        break;

    case e_Operator_AssignmentSubtract:
        if(!is_void)
        {
            a_Overloads.push_back(overload(ref, ref, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::assignmentSubtract)));
            a_Overloads.push_back(overload(Vref, Vref, std_ptrdiff_t, operation_delegate_t(a_pDataPointerType, &DataPointerType::assignmentSubtract)));
        }
        break;
    }
}
示例#18
0
void BuiltInOperator::addOverload( Type* a_pResult, Type* a_pOp0, Type* a_pOp1, operation_delegate_t a_Delegate )
{
    m_Overloads.push_back(overload(a_pResult, a_pOp0, a_pOp1, a_Delegate));
}
示例#19
0
int main() {
    // # Overload
    {
        assert(overload(1) == "i");

        //base type conversions
        {
            assert(overload(1.0f) == "f");

            /*
            ERROR: ambiguous overload(int) overload(float)

            Compiler does not know wether convert double to float or int.
            */
            //overload(1.0);
        }

        /*
        ERROR: ambiguous
        should compiler coverts to Base or BaseProtected? Both are possible via the default copy constructors.
        */
        {
            Class cOverload;
            //overloadBase(cOverload);
        }

        // ERROR: ambiguous
        //i=4;
        //overloadValAddr(i);

        /*
        # volatile overload

            Functions that differ by `volatile` can be overloaded:

            - http://stackoverflow.com/questions/10242578/volatile-overloading
        */
        {}

        /*
        Function pointer: decided by the typecast.

        http://stackoverflow.com/questions/2942426/how-to-specify-a-pointer-to-an-overloaded-function
        */
        {
            // Variable.
            {
                std::string (*fi)(int) = overload;
                std::string (*ff)(float) = overload;
            }
        }
    }

    /*
    In C++, unlike in C, definitions can omit argument names if they don't use those arguments!

    This probably exists for method overridding.
    */
    {
        assert(def_no_argname(0)    == 1);
        assert(def_no_argname(0, 0) == 2);
    }
}