More efficient A=B*C; of class type? C++

The expression
AA = BB * CC;
is evaluated making calling the operator* on B and C, possible code:
T operator*(const T& A, const T& B) {
T rv(A);
rv *= B;
return rv;
where *= does the 'right thing' for the type T.
Just after there is the assignment, possible code:
T& operator=(T rhs) {
rhs.swap(*this);
return *this;
Where swap() swaps (doh) without throwing exceptions.
At the moment it should goes that way:
rv is made and returned,
rv is copied in rhs,
rv is destroyed,
rhs swapped with AA,
a reference to AA is returned, but now AA contains the intended value,
rhs is destroyed, now it contains the old AA value.
Is it possible to avoid the double copy? i.e., using rv directly in the assignment?
I recall something about overloading the ternary operator, but seeking on google I find only stuff about :?, so I guess I recall wrongly.
Last edited by ezzetabi (2008-03-21 09:55:13)

Can you clarify for me please...  for you class T, the * operator needs to be defined but the *= operator works?  That just seems really, really strange.
Evaluation and assignment without temporaries is possible in C++ but it uses very advanced template overloading.  Look up "expression templates" if you are interested.
Also, ?: is the only ternary operator in C++.

Similar Messages

  • More than one class type for a Material

    Hi All,
    We have a requirement of using a Material for Variant configuration. So we need to assign Class type 300 for that Material.
    But that Material is Batch managed. So Class type 023 is already assigned. I am unable to extend the Material to Class type 300.
    I searched forum, it is given that, it is possible to maintain different Class types for a Material.
    But I tried, I couldn't do that.
    Please help me to extend a Material to another Class type.
    Regards,
    Raja Durai

    Hi Raja,
    You can maintain different classes for same material.
    Go to material master and go to Classification view. Go to Extras->Change class type (F7)
    Now you can add a class of different class type.
    Please see below snapshots for more details.
    Thanks,
    Dattatreya N R

  • Want to know more about class and class type and characters in batch determ

    hi ,
    i want to know abt class functionality and how it is related to batch mgt,means functions of class type , characters etc.
    ok thanks

    Hi ,
    Find the Class and Class Type for Batch Determination.
    Create Class for Batch Management
    Use
    In this step, you define two classes for use with batches. One class contains the characteristic LOBM_VFDAT: Expiration Date, and the other class with three characteristics:
    LOBM_RL: Remaining shelf life for batch,
    LOBM_LFDAT Batch determination delivery date, and
    LOBM_VFDAT Expiration date, shelf life.
    Procedure1.
    Access the activity using one of the following navigation options:
    Transaction Code: CL02SAP R/3 Role Menu     Installation ® Create Class for Batch Management
    2.Choose Create and maintain the necessary master data manually. The relevant data can be found in the file:
      Class     Class type     Description     Characteristic        Characteristic     Characteristic
    023_001     023     Products with Expiration Date     LOBM_VFDAT     
    023_002     023     Search class with expiration date     LOBM_RLZ     LOBM_LFDAT     LOBM_VFDAT
    Result
    The materials are later assigned to class 023_001 in the material masters. 023_002 is used in the batch determination search strategies for SD and PP/PI. 
    Regards,
    SAROSH

  • More-efficient keyboard

    Anyone have a way to get a better onscreen keyboard going than the QWERTY one that is stock on the iPhone? I love the FITALY (fitaly.com) keyboard on my old Palm, but that company says Apple won't let them do a system keyboard. One would like to think that a Dvorak or other non-18th century keyboard could be available among the international keyboards, but I don't find one.
    And yes, I've already tried the alternatives, e.g., TikiNotes, which takes me three times as long to type on than the Qwerty.
    If not, this would be a great suggestion for a new feature for Apple to incorporate.

    Just to let everybody know I am now 28 years old. I first learned how to type in typing class in junior high. I was using the Qwerty layout. The only nice thing I can say about the Qwerty layout is that it's available at any computer you want to use without any configuration.
    Then I looked online for a better way to type and more efficient. That's when I learned about Dvorak keyboard layout. This was about four years ago. I stuck with it for about two years. I felt my right hand was doing a lot more typing than my left hand. It felt too lopsided for me. But that's just my opinion. I went on the hunt for something better than Dvorak and I found the glorious Colemak keyboard layout.
    I have been typing with it ever since. My hands are a lot more comfortable and I can type faster now. It took me a month to actually get comfortable with the keyboard layout. If you actually go to this Java applet on Colemak's website.
    www.colemak.com/Compare
    You can just copy and paste a body of text and click on Calculate it will analyze the typing and compare the three different keyboard layouts. I just hope it becomes an ANSI standard like Dvorak has. I hope that happens in the future.
    I just want everybody to know there is a third option out there and its great. If ever Colemak goes away I will be going back to Dvorak. I will never learn the Qwerty keyboard layout ever again.
    Just wanted to give my two cents worth.

  • Why is Array more efficient than flexible-size collection

    it is a bit more tricky to understand the two advantges of Array as following:
    1. access to items held in an array is often more efficient than access to the items in a comparable flexible-size collection,
    2. arrays are able to store objects or primitive -type values, but flexible -size collection can store only object.
    thanks in advance

    it is a bit more tricky to understand the two
    wo advantges of Array as following:
    1. access to items held in an array is often more
    e efficient than access to the items in a comparable
    flexible-size collection,The standard dynamic data structure (with standard I mean member of the collections framework) comparable to the array is the ArrayList. In principle the access to an element is equally efficient in both cases. (There's some overhead because you have to do a method call in the ArrayList case). It's only in very low-level algoritms you need to use arrays. In most cases ArrayList is fine.
    2. arrays are able to store objects or primitive
    ve -type values, but flexible -size collection can
    store only object.This is true with the standard collection, but there are alternative collections that can store primitives, for example,
    http://pcj.sourceforge.net/
    In the next version of Java there's a new concept call autoboxing. This means there's an implicit conversion taking place between primitive types and their corresponding wrapper class, say between int and Integer. This means you will be able to write your program AS IF you could store primitives in the standard collections.

  • WHICH CLASS type of 4GB microSDHC does 5610XM supp...

    1. Any microSD(T-Flash)more than 2GB is known as "microSDHC".
    2. A 4GB microSDHC has three(3)class types, which are Class 2, Class 4 and Class 6.
    3. 5610XM can support microSDHC upto 4GB.
    Seems that there is no mention in the manual regarding to the captioned. I wonder if class 4 or class 6 - 4GB T-Flash (microSDHC)will 5610XM support?
    My question is "WHICH CLASS type of 4GB microSDHC does 5610XM support?"
    Please give a hand~~ many thanks!
    Quoted from -
    http://www.sandisk.com/Assets/File/pdf/retail/SDHC1.pdf
    What is Class Speed Rating?
    The SD Association has created and defined 3 speed classes to help you identify speed and performance capabilities/minimum requirements of SD/SDHC, miniSD/miniSDHC, and microSD/microSDHC cards and the host products.
    The SD Speed Class Ratings specify a minimum sustained write speed for SDHC/miniSDHC/microSDHC cards (Class 2: 2 MB/s; Class 4: 4 MB/s; Class 6: 6 MB/s*).

    Sandisk SDHC cards will work with the 5610. It is unknown if cards larger than 4GB will work, as no one has mentioned it yet.
    Here are the specs for the sandisk card:
    http://www.sandisk.com/Products/Item(2369)-SDSDQ-4096-SanDisk_microSDHC_4GB.aspx
    .Message Edited by psychomania on 27-Nov-200703:22 PM

  • What is the field and Table for "Batch Class" and "Class Type" in QM.

    Hi All,
    What is the field and Table for "Batch Class" and "Class Type" in QM.
    Thanks,

    Hi,
      For batch class the class type value is '023' . This you can find from KLAH table and the fileld for class type is KLART..
    And also all the data related to batch class are found in tables INOB, KLAH,KKSK and for the characeteristics of batch materials you can refer AUSP table.
    In INOB table, for batch class, you need to give 023 in KLART field and  value MCH1 in OBTAB filed.
    Please check this and let me know if this you need any more details?

  • Is it possible to maintain two class type for a material

    Dear All,
    Is it possible to maintain two different class type for a material.
    If a material assigned with the batch and the material is a part of variant configuration, then how to handle this scenario.
    For Batch Management, class type will be 023, for Variant Configuration class type will be 200.
    How to handle this scenario.
    Please explain.
    Regards,
    Mullairaja
    Edited by: MullaiRaja on Jan 5, 2011 5:19 AM

    Mr.Raja
    As far as my knowledge, it does NOT make sense to assign a material to more than one class type.
    We can assign many classes to  a single class type of  a material.
    For configurable material, create the material using material type : KMAT.
    & then, activate the 'batch management" control in the material master, for that material.
    Pls revert with feedback.
    Hope, that helps you.
    Rgds
    Sumanth.Gururaj
    Consultant/Systems Analyst - SAP SD/MM

  • Alias tables do not show more than 9 fields of the same type in a Command

    Hi there, In Crystal Reports I have a Command to query a database, this works fine and returns what I need,
    but in when you add more than 9 alias's and and then Select more thatn 9 fields of the same type it does not show any more them in the Field Exporler window.
    i.e. I want to add another alias and select casdet_text(10) but it does not show any more than 9.
    Any help woud be apprecitated.
    Thanks
    casdet_text(1)
    casdet_text(2)
    casdet_text(3)
    casdet_text(4)
    casdet_text(5)
    casdet_text(6)
    casdet_text(7)
    casdet_text(8)
    casdet_text(8)
    casdet_text(9)

    Hi James,
    It's likely an internal limitation. If you are going to alias all of your fields it's more efficient to use a View or Stored Procedure to handle the renaming server side rather than client side.
    It may even be a connection limit, try using another tool and see if you can add more than 9 aliases.
    Thank you
    Don

  • Cisco ACE loadbalancing matching more than one header in L7 class map

    Dear All,
    This is regarding Cisco ACE loadbalancing matching more than one header in L7 class map. I have a small setup with ACE 30 module in Cisco6500. I have got three webservers. Presently I have following configuration where I am mathing one url header.
    class-map type http loadbalance match-all L7_WEB_HEADER_MATCH
    description MATCH THE HOST HEADER OF HTTP REQUEST
    2 match http header Host header-value ".*abhisar.com*"
    So for above configuration, when traffic is coming for abhisar.com, it is working fine.
    Now, I have following headers and DNS entry is pointing to same virtual IP for all http url header same as abhisar.com
    abhisarindia.com
    indiaabhi.com
    So new configuration will be
    class-map type http loadbalance match-any L7_WEB_HEADER_MATCH
    description MATCH THE HOST HEADER OF HTTP REQUEST
    2 match http header Host header-value ".*abhisar.com*"
    4 match http header Host header-value ".*abhisarindia.com*"
    6 match http header Host header-value ".*indiaabhi.com*"
    So just want to confirm if this is fine.
    Thank You,
    Abhisar.

    Dear Rajesh,
    Thank you for reply. I will let you know once I carry out this activity.
    Thank You,
    Abhisar.

  • IN MATERIAL MASTER RECORD WHAT IS THE USE OF CLASS TYPE(CLASSIFICATION VIEW

    Hi Guys,
    Can you please explain what are the different critiria to use different class type and what exactly meaning of the each class type with respect to Material classification.
    Any material available on this to study. Please give link.
    Thanks,
    Dhanu

    Hi,
    Purpose
    The classification system allows you to use characteristics to describe all types of objects, and to group similar objects in classes u2013 to classify objects, in other words, so that you can find them more easily later.
    You then use the classes to help you to find objects more easily, using the characteristics defined in them as search criteria. This ensures that you can find objects with similar or identical characteristics as quickly as possible.
    Integration
    The classification system allows you to classify all types of object. First, you must define certain settings in Customizing for the classification system. For more information, see Customizing for the Classification System.
    SAP has predefined a number of object types (for example, materials, and equipment). The settings for these object types have already been defined in Customizing, so you can start to set up your classification system for these object types without defining further settings.
    Features
    Before you can use classification functions, you need to set up your classification system.
    The there are three steps to setting up a classification system:
    Defining the Properties of Objects
    You use characteristics to describe the properties of objects. You create characteristics centrally in the SAP R/3 System.
    See the SAP Library, Characteristics (CA-CL-CHR).
    Creating Classes
    You need classes to classify objects. These classes must be set up. During set up you must assign characteristics to the classes.
    Assigning Objects
    Once you have created the classes you require for classification, you can assign objects to these classes. You use the characteristics of the class to describe the objects you classify.
    This completes the data you require to use your classification system. You can then use your classification system to find objects that match the criteria you require.
    Once you have set up the classification system you can use it to find certain objects. To do this:
    Find a class in which objects are classified
    Find the object(s) you require in the class
    When you use classification to find objects, you use the characteristics as search criteria, and the system compares the values you enter with the values of the classified objects.
    Uts
    Award if helpfull

  • What are the main differences between  3 three important class types

    PP members
    What are the main differences between class type 300(variants) , class type 200 (configurable objects) & 001 ( material class)
    Please elucidate on the above
    Thanks
    Suren R

    Hi,
    The class type is a central concept in the classification system. The class type determines how classes are processed, and how objects can be classified and retrieved in these classes. In Customizing for Classification, you define the settings for a class type. You define class types for a specific object type, such as materials. You can then use classes of this class type to classify objects of this object type.
    When you first create a class, you must enter a class type for the class. Each class type is a closed system. There is no link between the different class types.
    he class type determines the following:
    Which object types you can assign to a class
    Which class maintenance functions you can process
    Whether you can classify objects in more than one class
    Which class statuses, organizational areas, and text types are supported in class maintenance functions
    Whether you can use engineering change management for classification
    Which filter functions you can use to restrict the search result
    All materials can be classified with class type 001. Class type 300 is for variant configuration the variants under a class item are called as variants and can be picked during sales order creation. Class type 200 is for classes that are used as class items in bills of material. You can classify the same materials separately in these class types.
    This is basically used to differentiate the BOM class items.
    Prakash

  • Multi value selection for characteristics under class type 200

    Hello Experts,
    Please suggest
    I am trying to assign a class type 200 to the material master of a component say ABC.
    While selecting the values for chars under classification I need to select more than one value for a characteristics say XYZ(single value).
    Because when the K item will be replaced by L item from my class BOM, I want ABC to be in the BOM expolsion for  ANY of the multiple values I select under classification of ABC.
    Thanks,
    Santosh

    Santosh Kumar,
    Thanks for providing example, here the problem is , during replacement of class with material number system looks for exact match.
    In classification view you cant put or condition, what ever value we assigned there is consider as AND replationship.
    you can create 3 similar material , and assign them this combination , like for XYZ1 , model is A1, XYZ2 , Model =A2 etc
    or
    For such requirement , the better option is instead of class put material number directly in BOM with item catagory L and assign selection condition with logic select this component if MODEL =  A2 or A3 or B1 and DOR=CW & MOC=CI
    It will work , with class node it will not work.
    Please also check document created by me on class node in below link.
    Classes as place holders [Components in Super BOM]
    Thanks
    Ritesh

  • Make Code More Efficient

    I got this code to play some audio clips and it works alright. The only issue is that when I call the play method it lags the rest of my game pretty badly. Is there anything in the play method you guys think could be moved to the constructor to make it more efficient?
    package main;
    import java.io.*;
    import javax.sound.sampled.*;
    public class Sound
         private AudioFormat format;
        private byte[] samples;
        private String name;
         public Sound(String filename)
              name=filename;
              try
                AudioInputStream stream =AudioSystem.getAudioInputStream(new File("sounds/"+filename));
                format = stream.getFormat();
                samples = getSamples(stream);
            }catch (Exception e){System.out.println(e);}
         public byte[] getSamples()
            return samples;
        private byte[] getSamples(AudioInputStream audioStream)
            int length=(int)(audioStream.getFrameLength()*format.getFrameSize());
            byte[] samples = new byte[length];
            DataInputStream is = new DataInputStream(audioStream);
            try
                is.readFully(samples);
            }catch (Exception e){System.out.println(e);}
            return samples;
        public void play()
             InputStream stream =new ByteArrayInputStream(getSamples());
            int bufferSize = format.getFrameSize()*Math.round(format.getSampleRate() / 10);
            byte[] buffer = new byte[bufferSize];
            SourceDataLine line;
            try
                DataLine.Info info=new DataLine.Info(SourceDataLine.class, format);
                line=(SourceDataLine)AudioSystem.getLine(info);
                line.open(format, bufferSize);
            }catch (Exception e){System.out.println(e);return;}
            line.start();
            try
                int numBytesRead = 0;
                while (numBytesRead != -1)
                    numBytesRead =
                        stream.read(buffer, 0, buffer.length);
                    if (numBytesRead != -1)
                       line.write(buffer, 0, numBytesRead);
            }catch (Exception e){System.out.println(e);}
            line.drain();
            line.close();
        public String getName()
             return name;
    }

    I don't know much about the guts of flex, but I assume it's
    based on Java's design etc.
    Storing event.target.selectedItem in an objet should not be
    anymore efficient than calling event.target.selectedItem. The objet
    will simply be a pointer of sorts to event.target.selectedItem. At
    no point in the event.target.selectedItem call are you doing a
    search or something, so storing the result will not result in any
    big savings.
    Now, if you were doing something like
    array.findItem(something) 4 times, then yes, it would be to your
    advantage to store the data.
    Keep in mind that storing event.target.selectedItem in an
    object will probably break bindings....that may or may not be a
    problem. Objet doesn't support binding. There is a subclass of
    Object that does, but I forget which.
    Just a suggestion based on my knowledge of how data is stored
    in an object oriented language...this may not be the case in
    flex.

  • Would PHP or Python work more efficiently to grab from a MSSQL database in AS3?

    Would PHP or Python work more efficiently to grab information from a MSSQL database in AS3? How would it work? Thanks!

    that's not a flash issue. 
    but here's a comparison, http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=all&lang=python&lang2=php
    which looks like python would be faster at data handling and slow at arithmetic operations.
    you would call both server-side scripts using the urlloader class from flash.

Maybe you are looking for

  • Apple ID password request that don't belong to me

    I recently bought a new iPhone to replace my old one. I made the activation at a local store and after I restored my content via iCloud I encountered on numerious ocassions that my iPhone starts blasting me with requests to enter the Apple ID passwor

  • Best practice: text/value formatting based on a value

    Hi all. How would you make a field display different text/value based on the actual value of a field? I have a field in a bean called retriesPerSecs. If this value is less than 1, then I want to display the text/value "{retriesPerSecs*60} retries per

  • Adding objects to Vectors

    I am currently working for the first time with Vectors and don't seem to be able to get my head around something: I want to store an undefined amount of "Line" objects in my vector. So what I tried is this: Vector vecLines = new Vector(); vecLines.ad

  • BASIS query :how to transport user roles

    BASIS query :how to transport user roles regards Mave

  • Replica-aware stub.

    Hi, Can anyone explain about replica aware stub. Thanks in advance. Regards, Vardhan.