Search Results

Search found 46790 results on 1872 pages for 'type systems'.

Page 15/1872 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Unity: Replace registered type with another type at runtime

    - by gehho
    We have a scenario where the user can choose between different hardware at runtime. In the background we have several different hardware classes which all implement an IHardware interface. We would like to use Unity to register the currently selected hardware instance for this interface. However, when the user selects another hardware, this would require us to replace this registration at runtime. The following example might make this clearer: public interface IHardware { // some methods... } public class HardwareA : IHardware { // ... } public class HardwareB : IHardware { // ... } container.RegisterInstance<IHardware>(new HardwareA()); // user selects new hardware somewhere in the configuration... // the following is invalid code, but can it be achieved another way? container.ReplaceInstance<IHardware>(new HardwareB()); Can this behavior be achieved somehow? BTW: I am completely aware that instances which have already been resolved from the container will not be replaced with the new instances, of course. We would take care of that ourselves by forcing them to resolve the instance once again.

    Read the article

  • Avoid incompatible pointer warning when dealing with double-indirection

    - by fnawothnig
    Assuming this program: #include <stdio.h> #include <string.h> static void ring_pool_alloc(void **p, size_t n) { static unsigned char pool[256], i = 0; *p = &pool[i]; i += n; } int main(void) { char *str; ring_pool_alloc(&str, 7); strcpy(str, "foobar"); printf("%s\n", str); return 0; } ... is it possible to somehow avoid the GCC warning test.c:12: warning: passing argument 1 of ‘ring_pool_alloc’ from incompatible pointer type test.c:4: note: expected ‘void **’ but argument is of type ‘char **’ ... without casting to (void**) (or simply disabling the compatibility checks)? Because I would very much like to keep compatibility warnings regarding indirection-level...

    Read the article

  • How to determine MIME Type set by htaccess in PHP

    - by Ed Marty
    I have a .htaccess file set up to define specific MIME types in directory root/a/b/, and all of the files are in the same directory. I have a php file that wants to serve those files, in directory root/c/, and needs to determine the content-type as defined by the .htaccess file. Is there any way to do this? PHP version is 5.1.6. mime_content_type returns text/plain, and I'd rather not try to parse the .htaccess file manually. I can move the file if necessary.

    Read the article

  • Compile time error: cannot convert from specific type to a generic type

    - by Water Cooler v2
    I get a compile time error with the following relevant code snippet at the line that calls NotifyObservers in the if construct. public class ExternalSystem<TEmployee, TEventArgs> : ISubject<TEventArgs> where TEmployee : Employee where TEventArgs : EmployeeEventArgs { protected List<IObserver<TEventArgs>> _observers = null; protected List<TEmployee> _employees = null; public virtual void AddNewEmployee(TEmployee employee) { if (_employees.Contains(employee) == false) { _employees.Add(employee); string message = FormatMessage("New {0} hired.", employee); if (employee is Executive) NotifyObservers(new ExecutiveEventArgs { e = employee, msg = message }); else if (employee is BuildingSecurity) NotifyObservers(new BuildingSecurityEventArgs { e = employee, msg = message }); } } public void NotifyObservers(TEventArgs args) { foreach (IObserver<TEventArgs> observer in _observers) observer.EmployeeEventHandler(this, args); } } The error I receive is: The best overloaded method match for 'ExternalSystem.NotifyObservers(TEventArgs)' has some invalid arguments. Cannot convert from 'ExecutiveEventArgs' to 'TEventArgs'. I am compiling this in C# 3.0 using Visual Studio 2008 Express Edition.

    Read the article

  • Clojure warn-on-reflection and type hints

    - by Ralph
    In the following code, I am getting a warning on reflection: (ns com.example (:import [org.apache.commons.cli CommandLine Option Options PosixParser])) (def *help-option* "help") (def *host-option* "db-host") (def *options* (doto (Options.) (.addOption "?" *help-option* false "Show this usage information") (.addOption "h" *host-option* true "Name of the database host"))) (let [^CommandLine command-line (.. (PosixParser.) (parse *options* (into-array String args))) db-host (.getOptionValue command-line "h")] ; WARNING HERE ON .getOptionValue ; Do stuff with db-host ) I have a type hint on command-line. Why the warning? I am using Clojure 1.2 on OS X 10.6.6 (Apple VM). I assume that I do not get a warning on (.addOption ...) because the compiler knows that (Options.) is a org.apache.commons.cli.Options).

    Read the article

  • Return an opaque object to the caller without violating type-safety

    - by JS Bangs
    I have a method which should return a snapshot of the current state, and another method which restores that state. public class MachineModel { public Snapshot CurrentSnapshot { get; } public void RestoreSnapshot (Snapshot saved) { /* etc */ }; } The state Snapshot class should be completely opaque to the caller--no visible methods or properties--but its properties have to be visible within the MachineModel class. I could obviously do this by downcasting, i.e. have CurrentSnapshot return an object, and have RestoreSnapshot accept an object argument which it casts back to a Snapshot. But forced casting like that makes me feel dirty. What's the best alternate design that allows me to be both type-safe and opaque?

    Read the article

  • which type is best for three radiobuttons?

    - by Manog
    Maybe you consider this question trivial but im just curious what is your opinion. I have three radiobuttons. "Show blue", "Show red" and "Show all". I did it with nullable boolean. There is collumn in database where blue is 0 and red is 1 so in metode i have to translate bool to int to compare those values (i do it in c#).Of course it works, but i wonder if it is the best solution. And question is wich type is best in this case? nullable bool, int, or maybe string?

    Read the article

  • Switch Case on type of object (C#)

    - by Sem Dendoncker
    If you want to switch a type of object, what is the best way to do this? ex: private int GetNodeType(NodeDTO node) { switch (node.GetType()) { case typeof(CasusNodeDTO): return 1; case typeof(BucketNodeDTO): return 3; case typeof(BranchNodeDTO): return 0; case typeof(LeafNodeDTO): return 2; default: return -1; } } I know this doesn't work that way, but I was wondering how you could solve this. Is an if then else else else statement appropriate in this case? Or do you use this switch and add .ToString() to the types? Kind regards, Sem

    Read the article

  • Implicit type conversion in DB/2 inserts?

    - by IronGoofy
    We're using SQL Inserts to insert some data via a script into DB/2 tables, e.g. CREATE TABLE TICKETS (TICKETID VARCHAR(10) NOT NULL); On my home installation, this statement works fine (note that I'm using an integer which is autoatically cast into a VarChar): INSERT INTO TICKETS (TICKETID) VALUES (1); while at my customer's site I get a type error. My question(s): Is this behavior version dependent? (I use a DB2 Express V9.7, while the customer has an Enterprise V9.5) Is there a config option to change the behavior? (I would like my home install to behave as close as possible as the production environment is going to be.)

    Read the article

  • Learn Lean Software Development and Kanban Systems

    - by Ben Griswold
    I did an in-house presentation on Lean Software Development (LSD) and Kanban Systems this week.  Beyond what I had previously learned from various podcasts, I knew little about either topic prior to compiling my slide deck.  In the process of building my presentation, I learned a ton.  I found the concepts weren’t very difficult to grok; however, I found little detailed information was available online. Hence this post which is merely a list of valuable resources. Principles of Lean Thinking, Mary Poppendieck Lean Software Development, May Poppendieck Lean Programming, Mary Poppendieck Lean Software Development, Wikipedia Implementing Lean Software Thinking: From Concept to Cash, Poppendieck Lean Software Development Overview, Darrell Norton Lean Thinking: Banish Waste and Create Wealth in Your Corporation The Goal: A Process of Ongoing Improvement The Toyota Way Extreme Toyota: Radical Contradictions That Drive Success at the World’s Best Manufacturer Elegant Code Cast 17 – David Laribee on Lean / Kanban Herding Code Episode 42: Scott Bellware on BDD and Lean Development Seven Principles of Lean Software Development, Przemys?aw Bielicki Kanban Boards for Agile Project Management with Zen Author Nate Kohari Herding Code 55: Nate Kohari brings Your Moment of Zen James Shore on Kanban Systems Agile Zen Product Site A Leaner Form of Agile, David Laribee Kanban as Alternative Agile Implementation, Mark Levison Lean Software Development, Dr. Christoph Steindl Glossary of Lean Manufacturing Terms Why Pull? Why Kanban?, Corey Ladas

    Read the article

  • Java Spotlight Episode 99: Daniel Blaukopf on JavaFX for Embedded Systems

    - by Roger Brinkley
    Interview with  Daniel Blaukopf on JavaFX for Embedded Systems Right-click or Control-click to download this MP3 file. You can also subscribe to the Java Spotlight Podcast Feed to get the latest podcast automatically. If you use iTunes you can open iTunes and subscribe with this link:  Java Spotlight Podcast in iTunes. Show Notes News Top 5 Reasons to go to JavaOne 5. Chance to see the future of Java Technical Keynotes and sessions The pavillion The new Embedded@JavaOne conference 4. The meetings outside the scope of the conference Top 10 Reasons to Attend the Oracle Appreciation Event GlassFish Community Event at JavaOne 2012 Sundays User Group Forum 3. It’s like drinking from firehose Less keynotes more sessions - 20% more 60% of the talks are external to HOLs Tutorials OracleJava University classes on Sunday - Top Five Reasons You Should Attend Java University at JavaOne 2. Students are free 1. It’s not what you see it’s who you will meet Events Sep 10-15, IMTS 2012 Conference,  Chicago Sep 12,  The Coming M2M Revolution: Critical Issues for End-to-End Software and Systems Development,  Webinar Sep 30-Oct 4, JavaONE, San Francisco Oct 3-4, Java Embedded @ JavaONE, San Francisco Oct 15-17, JAX London Oct 30-Nov 1, Arm TechCon, Santa Clara Oct 22-23, Freescale Technology Forum - Japan, Tokyo Oct 31, JFall, Netherlands Nov 2-3, JMagreb, Morocco Nov 13-17, Devoxx, Belgium Feature InterviewDaniel Blaukopf is the Embedded Java Client Architect at Oracle, working on JavaFX. Daniel's focus in his 14 years in the Java organization has been mobile and embedded devices, including working with device manufacturers to port and tune all levels of the Java stack to their hardware and software environments. Daniel's particular interests are: graphics, performance optimization and functional programming.

    Read the article

  • Design for XML mapping scenarios between two different systems [on hold]

    - by deepak_prn
    Mapping XML fields between two systems is a mundane routine in integration scenarios. I am trying to make the design documents look better and provide clear understanding to the developers especially when we do not use XSLT or any other IDE such as jDeveloper or eclipse plugins. I want it to be a high level design but at the same time talk in developer's language. So that there is no requirements that slip under the crack. For example, one of the scenarios goes: the store cashier sells an item, the transaction data is sent to Data management system. Now, I am writing a functional design for the scenario which deals with mapping XML fields between our system and the data management system. Question : I was wondering if some one had to deal with mapping XML fields between two systems? (without XSLT being involved) and if you used a table to represent the fields mapping (example is below) or any other visualization tool which does not break the bank ? I am trying to find out if there is a better way to represent XML mapping in your design documents. The widely accepted and used method seems to be using a simple table such as in the picture to illustrate the mapping. I am wondering if there are alternate ways/ tools to represent such as in Altova:

    Read the article

  • Actually utilizing relational databases for entity systems

    - by Marc Müller
    Recently I was researching several entity systems and obviously I came across T=Machine's fantastic articles on the subject. In Part 5 of the series the author uses a relational schema to explain how an entity system is built and works. Since reading this, I have been wondering whether or not actually using a compact SQL library would be fast enough for real-time usage in video games. Performance seems to be the main issue with a full blown SQL database for management of all entities and components. However, as mentioned in T=Machine's post, basically all access to data inside the SQLDB is done sequentlially by each system over each component. Additionally, using a library like SQLite, one could easily improve performance by storing the entity data exclusively in RAM to increase access speeds. Disregarding possible performance issues, using a SQL database, in my opinion, would allow for a very intuitive implementation of entity systems and bring a long certain other benefits like easy de/serialization of game states and consistency checks like the uniqueness of entity IDs. Edit for clarification: The main question was whether using a SQL database for the actual entity management (not just storing the game state on the disk) in a real-time game would still yield a framerate appropriate for a game or even if someone is aware of projects that demonstrate SQL in a video game.

    Read the article

  • Event notifications for Reporting Systems

    - by Marc Schluper
    The last couple of months I have been working on an application that allows people to browse a data mart. Nice, but nothing new. In this context I have an idea that I want to publish before anyone else patents it: event notifications. You see, reporting systems are not used as much as we’d like. Typically, users don’t know where to look for reports that might interest them. At best, there are some standard reports that people generate every so often, i.e. based on a time trigger. Or some reporting systems can be configured to send monthly reports around, for convenience. But apart from that, the reporting system is just sitting there, waiting for the rare curious user who makes the effort to dig a bit for treasures to be found. Wouldn’t it be great if there were data triggers? Imagine we could configure the reporting system to let us know when something interesting has happened. It would send us a message containing a link that would take us to the relevant section of the reporting system, showing a report with all the data pertaining to that event, preparing us for proper actions. Here in the North West this would really be great. You see, it rains here most of the time from October to June, so why even check the weather forecast? But sometimes, sometimes it snows. And sometimes the sun shines. So rather than me going to the weather site and seeing over and over again that it will be raining, making me think “why bother?” I’d like to configure the weather site so that it lets me know when the rain stops. Now, hopefully nobody has patented this idea already. Let me know.

    Read the article

  • Engineered Systems: Oracle schlägt drei Fliegen mit einer Klappe

    - by A&C Redaktion
    Die News aus dem Partnergeschäft von Oracle sorgen für Schlagzeilen im Magazin ChannelPartner. Über den neuen Fokus auf Engineered Systems und die SMB Appliances heißt es dort, so könne Oracle „drei Fliegen mit einer Klappe schlagen“: Erstens wird früheren Sun Hardware-Resellern der Einstieg ins Software-Geschäft erleichtert, zweitens bieten die Appliances neue Möglichkeiten für den Mittelstand und drittens bekräftigt die Strategie das zweistufige Channel-Modell. Dazu Silvia Kaske, Senior Director Channel Sales & Alliances Oracle Deutschland: "Wir stärken weltweit den Channel, weil das SMB-Geschäft zunehmend anzieht." Neben der durchaus positiven Wertung der Channel-Strategie bietet der Artikel einen anschaulichen Überblich darüber, was Engineered Systems eigentlich sind. Außerdem werden die Einsatzmöglichkeiten (Big Data, Mobile Computing, Cloud etc.) und Angebote von Oracle in diesem Bereich dargestellt und diskutiert. Das Highlight hierbei ist – wen wundert’s – die Oracle Database Appliance. Mit dem Portfolio wächst natürlich auch die Zahl der Spezialisierungen. Logisch, findet Silvia Kaske: "Endkunden erwarten keine Generalisten, sondern Spezialisten. Nur mit einem klaren Fokus wird der Partner erfolgreich sein". Hier geht’s zum vollständigen CP-Artikel unter dem Titel „Oracle lockt Channel mit SMB-Appliances“.

    Read the article

  • Entity Framework and distributed Systems

    - by Dirk Beckmann
    I need some help or maybe only a hint for the right direction. I've got a system that is sperated into two applications. An existing VB.NET desktop client using Entity Framework 5 with code first approach and a asp.net Web Api client in C# that will be refactored right yet. It should be possible to deliver OData. The system and the datamodel is still involving and so migrations will happen in undefined intervalls. So I'm now struggling how to manage my database access on the web api system. So my favourd approch would be us Entity Framework on both systems but I'm running into trouble while creating new migrations. Two solutions I've thought about: Shared Data Access dll The first idea was to separate the data access layer to a seperate project an reference from each of the systems. The context would be the same as long as the dll is up to date in each system. This way both soulutions would be able to make a migration. The main problem ist that it is much more complicate to update a web api system than it is with the client Click Once Update Solution and not every migration is important for the web api. This would couse more update trouble and out of sync libraries Database First on Web Api The second idea was just to use the database first approch an on web api side. But it seems that all annotations will be lost by each model update. Other solutions with stored procedures have been discarded because of missing OData support and maintainability. Does anyone run into same conflicts or has any advices how such a problem can be solved!

    Read the article

  • Security in Robots and Automated Systems

    - by Roger Brinkley
    Alex Dropplinger posted a Freescale blog on Securing Robotics and Automated Systems where she asks the question,“How should we secure robotics and automated systems?”.My first thought on this was duh, make sure your robot is running Java. Java's built-in services for authentication, authorization, encryption/confidentiality, and the like can be leveraged and benefit robotic or autonomous implementations. Leveraging these built-in services and pluggable encryption models of Java makes adding security to an exist bot implementation much easier. But then I thought I should ask an expert on robotics so I fired the question off to Paul Perrone of Perrone Robotics. Paul's build automated vehicles and other forms of embedded devices like auto monitoring of commercial vehicles on highways.He says that most of the works that robots do now are autonomous so it isn't a problem in the short term. But long term projects like collision avoidance technology in automobiles are going to require it.Some of the work he's doing with his Java-based MAX, set of software building blocks containing a wide range of low level and higher level software modules that developers can use to build simple to complex robot and automation applications faster and cheaper, already provide some support for JAUS compliance and because their based on Java, access to standards based security APIs.But, as Paul explained to me, "the bottom line is…it depends on the criticality level of the bot, it's network connectivity, and whether or not a standards compliance is required."

    Read the article

  • Sub-systems in game engines

    - by Hillel
    So here's the problem- I'm writing my own engine library, and it works fine with stuff like menus and the actual game screen. The thing is, I can't really figure out how to integrate something like an intro or dialogue preceding certain levels into this system. Let's look at another example- say I have a game-specific engine which gets a Level object and runs it. Engine would have its own collision and physics system, all hard coded. Now, what if at some point in a level, I want the player to enter a mini-game with different rules? How do I morph the Engine class to support these sub-systems without having to deal with their code all the time (as in: if(regular game) ... else if(mini game) ...)? And what if I want an intro animation at the start of a level, and I want the player to be able to assume control of his character once the animation ends, do I implement the animation into the Engine class itself? Or maybe I need to run another class, CutScene, and when it ends, it calls Engine and starts the level? What if I want to add a dialogue system, where at the start of each level there's a short dialogue and the player can't control his character, and once it ends, he can? Would I then run the dialogue code inside the Engine code? Maybe these sub-systems should all be scripted? I don't know anything about scripting, is it necessary for this kind of situation? Any help would be appreciated.

    Read the article

  • SQL SERVER – MSQL_XP – Wait Type – Day 20 of 28

    - by pinaldave
    In this blog post, I am going to discuss something from my field experience. While consultation, I have seen various wait typed, but one of my customers who has been using SQL Server for all his operations had an interesting issue with a particular wait type. Our customer had more than 100+ SQL Server instances running and the whole server had MSSQL_XP wait type as the most number of wait types. While running sp_who2 and other diagnosis queries, I could not immediately figure out what the issue was because the query with that kind of wait type was nowhere to be found. After a day of research, I was relieved that the solution was very easy to figure out. Let us continue discussing this wait type. From Book On-Line: ?MSQL_XP occurs when a task is waiting for an extended stored procedure to end. SQL Server uses this wait state to detect potential MARS application deadlocks. The wait stops when the extended stored procedure call ends. MSQL_XP Explanation: This wait type is created because of the extended stored procedure. Extended Stored Procedures are executed within SQL Server; however, SQL Server has no control over them. Unless you know what the code for the extended stored procedure is and what it is doing, it is impossible to understand why this wait type is coming up. Reducing MSQL_XP wait: As discussed, it is hard to understand the Extended Stored Procedure if the code for it is not available. In the scenario described at the beginning of this post, our client was using third-party backup tool. The third-party backup tool was using Extended Stored Procedure. After we learned that this wait type was coming from the extended stored procedure of the backup tool they were using, we contacted the tech team of its vendor. The vendor admitted that the code was not optimal at some places, and within that day they had provided the patch. Once the updated version was installed, the issue on this wait type disappeared. As viewed in the wait statistics of all the 100+ SQL Server, there was no more MSSQL_XP wait type found. In simpler terms, you must first identify which Extended Stored Procedure is creating the wait type of MSSQL_XP and see if you can get in touch with the creator of the SP so you can help them optimize the code. If you have encountered this MSSQL_XP wait type, I encourage all of you to write how you managed it. Please do not mention the name of the vendor in your comment as I will not approve it. The focus of this blog post is to understand the wait types; not talk about others. Read all the post in the Wait Types and Queue series. Note: The information presented here is from my experience and there is no way that I claim it to be accurate. I suggest reading Book OnLine for further clarification. All the discussion of Wait Stats in this blog is generic and varies from system to system. It is recommended that you test this on a development server before implementing it to a production server. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, SQL Wait Stats, SQL Wait Types, T SQL, Technology

    Read the article

  • Another BC30002: Type is not defined.

    - by brett
    Here's what I've done... I used wsdl.exe to create a .cs class for my wsdl service connection. I made a Visual Studio project to compile the .cs into a dll having namespace CalculatorService (CalculatorService.dll). Successful thus far. I created an asp.net project added my namespace import: %@ Import Namespace="CalculatorService" % I right-clicked on the project, clicked Add Reference, found my .dll, added it, built the project, checked /bin to ensure my dll was there (and it was). % 'I called the namespace:' Dim calcService As New CalculatorService.CalculatorService() 'called the function from the service' Dim xmlResult = calcService.GetSVS_ItemTable_XML("", "", "", "", "", "") 'printed the result' Response.Write(xmlResult) % All is well LOCALLY while debugging. It found the CalculatorService, connected to it, got the XML and displayed it. I then wanted to put it on the web so I built and published my project: under "Copy" - Only files needed to run this application...selected! Deploying on the web says Type 'CalculatorService.CalculatorService' is not defined. Here is a link to the live script: http://vansmith.com/_iaps.wsdl/pub/Default.aspx Any ideas?

    Read the article

  • How to create this MongoMapper custom data type?

    - by Kapslok
    I'm trying to create a custom MongoMapper data type in RoR 2.3.5 called Translatable: class Translatable < String def initialize(translation, culture="en") end def languages end def has_translation(culture)? end def self.to_mongo(value) end def self.from_mongo(value) end end I want to be able to use it like this: class Page include MongoMapper::Document key :title, Translatable, :required => true key :content, String end Then implement like this: p = Page.new p.title = "Hello" p.title(:fr) = "Bonjour" p.title(:es) = "Hola" p.content = "Some content here" p.save p = Page.first p.languages => [:en, :fr, :es] p.has_translation(:fr) => true en = p.title => "Hello" en = p.title(:en) => "Hello" fr = p.title(:fr) => "Bonjour" es = p.title(:es) => "Hola" In mongoDB I imagine the information would be stored like: { "_id" : ObjectId("4b98cd7803bca46ca6000002"), "title" : { "en" : "Hello", "fr" : "Bonjour", "es" : "Hola" }, "content" : "Some content here" } So Page.title is a string that defaults to English (:en) when culture is not specified. I would really appreciate any help.

    Read the article

  • Weird compile-time behavior when trying to use primitive type in generics

    - by polygenelubricants
    import java.lang.reflect.Array; public class PrimitiveArrayGeneric { static <T> T[] genericArrayNewInstance(Class<T> componentType) { return (T[]) Array.newInstance(componentType, 0); } public static void main(String args[]) { int[] intArray; Integer[] integerArray; intArray = (int[]) Array.newInstance(int.class, 0); // Okay! integerArray = genericArrayNewInstance(Integer.class); // Okay! intArray = genericArrayNewInstance(int.class); // Compile time error: // cannot convert from Integer[] to int[] integerArray = genericArrayNewInstance(int.class); // Run time error: // ClassCastException: [I cannot be cast to [Ljava.lang.Object; } } I'm trying to fully understand how generics works in Java. Things get a bit weird for me in the 3rd assignment in the above snippet: the compiler is complaining that Integer[] cannot be converted to int[]. The statement is 100% true, of course, but I'm wondering WHY the compiler is making this complaint. If you comment that line, and follow the compiler's "suggestion" as in the 4th assignment, the compiler is actually satisfied!!! NOW the code compiles just fine! Which is crazy, of course, since like the run time behavior suggests, int[] cannot be converted to Object[] (which is what T[] is type-erased into at run time). So my question is: why is the compiler "suggesting" that I assign to Integer[] instead for the 3rd assignment? How does the compiler reason to arrive to that (erroneous!) conclusion?

    Read the article

  • Argument type deduction, references and rvalues

    - by uj2
    Consider the situation where a function template needs to forward an argument while keeping it's lvalue-ness in case it's a non-const lvalue, but is itself agnostic to what the argument actually is, as in: template <typename T> void target(T&) { cout << "non-const lvalue"; } template <typename T> void target(const T&) { cout << "const lvalue or rvalue"; } template <typename T> void forward(T& x) { target(x); } When x is an rvalue, instead of T being deduced to a constant type, it gives an error: int x = 0; const int y = 0; forward(x); // T = int forward(y); // T = const int forward(0); // Hopefully, T = const int, but actually an error forward<const int>(0); // Works, T = const int It seems that for forward to handle rvalues (without calling for explicit template arguments) there needs to be an forward(const T&) overload, even though it's body would be an exact duplicate. Is there any way to avoid this duplication?

    Read the article

  • Is it the address bus size or the data bus size that determines "8-bit , 16-bit ,32-bit ,64-bit " systems?

    - by learner
    My simple understanding is as follows. Memory (RAM) is composed of bits, groups of 8 which form bytes, each of which can be addressed ,and hence byte addressable memory. Address Bus stores the location of a byte of memory. If an address bus is of size 32 bits, that means it can hold upto 232 numbers and it hence can refer upto 232 bytes of memory = 4GB of memory and any memory greater than that is useless. Data bus is used to send the value to be written to/read off the memory. If I have a data bus of size 32 bits, it means a maximum of 4 bytes can be written to/read off the memory at a time. I find no relation between this size and the maximum memory size possible. But I read here that: Even though most systems are byte-addressable, it makes sense for the processor to move as much data around as possible. This is done by the data bus, and the size of the data bus is where the names 8-bit system, 16-bit system, 32-bit system, 64-bit system, etc.. come from. When the data bus is 8 bits wide, it can transfer 8 bits in a single memory operation. When the data bus is 32 bits wide (as is most common at the time of writing), at most, 32 bits can be moved in a single memory operation. This says that the size of the data bus is what gives an OS the name, 8bit, 16bit and so on. What is wrong with my understanding?

    Read the article

  • Java Builder pattern with Generic type bounds

    - by I82Much
    Hi all, I'm attempting to create a class with many parameters, using a Builder pattern rather than telescoping constructors. I'm doing this in the way described by Joshua Bloch's Effective Java, having private constructor on the enclosing class, and a public static Builder class. The Builder class ensures the object is in a consistent state before calling build(), at which point it delegates the construction of the enclosing object to the private constructor. Thus public class Foo { // Many variables private Foo(Builder b) { // Use all of b's variables to initialize self } public static final class Builder { public Builder(/* required variables */) { } public Builder var1(Var var) { // set it return this; } public Foo build() { return new Foo(this); } } } I then want to add type bounds to some of the variables, and thus need to parametrize the class definition. I want the bounds of the Foo class to be the same as that of the Builder class. public class Foo<Q extends Quantity> { private final Unit<Q> units; // Many variables private Foo(Builder<Q> b) { // Use all of b's variables to initialize self } public static final class Builder<Q extends Quantity> { private Unit<Q> units; public Builder(/* required variables */) { } public Builder units(Unit<Q> units) { this.units = units; return this; } public Foo build() { return new Foo<Q>(this); } } } This compiles fine, but the compiler is allowing me to do things I feel should be compiler errors. E.g. public static final Foo.Builder<Acceleration> x_Body_AccelField = new Foo.Builder<Acceleration>() .units(SI.METER) .build(); Here the units argument is not Unit<Acceleration> but Unit<Length>, but it is still accepted by the compiler. What am I doing wrong here? I want to ensure at compile time that the unit types match up correctly.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >