Search Results

Search found 8397 results on 336 pages for 'implementation'.

Page 70/336 | < Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >

  • Allocation Target of std::aligned_storage (stack or heap?)

    - by Zenikoder
    I've been trying to get my head around the TR1 addition known as aligned_storage. Whilst reading the following documents N2165, N3190 and N2140 I can't for the life of me see a statement where it clearly describes stack or heap nature of the memory being used. I've had a look at the implementation provided by msvc2010, boost and gcc they all provide a stack based solution centered around the use of a union. In short: Is the memory type (stack or heap) used by aligned_storage implementation defined or is it always meant to be stack based? and, What the is the specific document that defines/determines that?

    Read the article

  • How to convince a colleague that code duplication is bad?

    - by vitaut
    A colleague of mine was implementing a new feature in a project we work on together and he did it by taking a file containing the implementation of a similar feature from the same project, creating a copy of it renaming all the global declarations and slightly modifying the implementation. So we ended up with two large files that are almost identical apart from renaming. I tried to explain that it makes our project more difficult to maintain but he doesn't want to change anything saying that it is easier for him to program in such way and that there is no reason to fix the code if it "ain't broke". How can I convince him that such code duplication is a bad thing? It is related to this questions, but I am more interested in the answers targeted to a technical person (another programmer), for example a reference to an authoritative source like a book would be great. I have already tried simple arguments and haven't succeeded.

    Read the article

  • Is there a way to localize input type="date" in HTML5

    - by lambacck
    I know that at the time of this writing only Opera supports a browser UI for <input type="date" name="mydate"> and maybe my attempts to localize this field have been met with frustration because niceties like localization have not yet been included in their implementation, but I don't even see mention of it in the HTML5 spec. Is there a way that localization should be specified? Should I do lang="fr" on a parent element? Some notes on the implementation of the site in question: Localization (language) is explicitly picked by the user because they are managing data in multiple languages and it is not reasonable to expect that the user's browser chrome is in the language being viewed or that the browser is providing desired language request headers. I want to be sure that if the page is rendered in French that the date picker provided by browser chrome shows options that make sense for French language. The plan is to fall back to jQueryUI for browsers that do not support type="date", I will use the detection mechanism provided in Dive into HTML 5

    Read the article

  • C++ - checking if a class has a certain method at compile time

    - by jetwolf
    Here's a question for the C++ gurus out there. Is there a way to check at compile time where a type has a certain method, and do one thing if it does, and another thing if it doesn't? Basically, I have a template function template <typename T> void function(T t); and I it to behave a certain way if T has a method g(), and another way if it doesn't. Perhaps there is something that can be used together with boost's enable_if? Something like this: template <typename T> enable_if<has_method<T, g, void ()>, void>::type function(T t) { // Superior implementation calling t.g() } template <typename T> disable_if<has_method<T, g, void ()>, void>::type function(T t) { // Inferior implementation in the case where T doesn't have a method g() } "has_method" would be something that preferably checks both that T has a method named 'g', and that the method has the correct signature (in this case, void ()). Any ideas?

    Read the article

  • Which libraries use the "We Know Where You Live" optimization for std::make_shared?

    - by KnowItAllWannabe
    Over two years ago, Stephan T. Lavavej described a space-saving optimization he implemented in Microsoft's implementation of std::make_shared, and I know from speaking with him that Microsoft has nothing against other library implementations adopting this optimization. If you know for sure whether other libraries (e.g., for Gnu C++, Clang, Intel C++, plus Boost (for boost::make_shared)) have adopted this implementation, please contribute an answer. I don't have ready access to that many make_shared implementations, nor am I wild about digging into the bowels of the ones I have to see if they've implemented the WKWYL optimization, but I'm hoping that SO readers know the answers for some libraries off-hand. I know from looking at the code that as of Boost 1.52, the WKWYL optimization had not been implemented, but Boost is now up to version 1.55. Note that this optimization is different from std::make_shared's ability to avoid a dedicated heap allocation for the reference count used by std::shared_ptr. For a discussion of the difference between WKWYL and that optimication, consult this question.

    Read the article

  • When did the idea of macros (user-defined code transformation) appear?

    - by Jay
    I have read McCarthy's 1960 paper on LISP and found no reference to anything that's similar to user-defined macros or normal order evaluation. I was wondering when marcos first appeared in programming language history (and also in Lisp history): When was the idea of user-defined code transformation (before interpretation or compilation) first described (theoretically)? What was the first programming language implementation to have Lisp-like macros (by "Lisp-like" I mean "using a readable Turing-complete language to do code-transformation")? (including non-Lisps -- Forth for example is quite old, but I'm not sure if the first Forth implementation already had "IMMEDIATE") What was the first Lisp dialect to have macros? Thank you!

    Read the article

  • Free PHP framework/library for single-sign on / cross domain login

    - by Dennis Cheung
    I am looking for free (non GPL is better) SSO framework/library implementation or code samples. There are many kind of SSO implementation. Sharing cookie, sharing session, one time token, associative accounts, etc, etc. (BTW, any good article compare them?) Is there any keyword I should google and reuse before before I start to implement our own wheel. I know OpenID, but which is too much and it is not our need. We rather keep it KISS. We just want share the credentials of user that could save users from another login form.

    Read the article

  • How to use the variable declared in one class in another class in Obj C.

    - by srikanth rongali
    I have a NSDate *date1 in class1 implementation file(I initialized it as Global variable). I have NSDate *date2 in class 2 implementation file (initialized it as Global variable). I need to calculate the NSTimeInterval between the two dates in class 2. But I could not do it. I could not access date1 in this class. It is giving error as (date2 undeclared). Please give me help in how to call other class variables in this class. Thank you.

    Read the article

  • Couldn't I just pass an copied string to an Core Data property?

    - by dontWatchMyProfile
    The docs say: The default implementation does not copy attribute values. If the attribute value may be mutable and implements the NSCopying protocol (as is the case with NSString, for example), you can copy the value in a custom accessor to help preserve encapsulation (for example, in the case where an instance of NSMutableString is passed as a value). So instead of getting into trouble and inconvenience with overwriting accessors in my NSManagedObject subclass, couldn't I simply do something like this? myManagedObject.firstName = [[firstNameMutableStr copy] autorelease]; This would have the exact same effect, or not? The dynamic implementation would retain that anyways ... so.... why not the easy way?

    Read the article

  • I want to use Google Map API for my Desktop application

    - by Nubkadiya
    i want to use google map api for my desktop application. the application will be totally connected to internet. while i was searching some research notes about this implementation. i found a ideal site with the configurations. but it has some java files to be downloaded. but when i tried that website its not loading. which is swinglabs.org http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html any other options of doing this api implementation to my desktop application. and one more thing. i tried downloading the google api. even it ask a url. we have to provide a url then only we get a key to download it. and the api should run in that specific url. otherwise its not working. how this appears to a desktop application any ideas welcome..

    Read the article

  • Objective C instance variables - Newbie

    - by Dwayne King
    OK - so I'm sure my confusion here is just a result of being stuck in a "Java mindset" and not understanding how Obj C differs in this case. In Java, I can declare a variable in a class, like this, and each instance of that class will have it's own: MyClass { String myVar; MyClass() { // constructor } } In Obj C I tried to do the same thing by declaring a variable only in the .m file like this: #import "MyClass.h" @implementation MyClass NSString *testVar; @end My expectation here was that this variable has a scope limited to this class. So I created a second class (identical): #import "MySecondClass.h" @implementation MySecondClass NSString *testVar; @end What I'm seeing (and has me baffled) is that changing the variable in one class, affects the value seen in the other class. In fact, if I set a breakpoint, and then "Jump to Definition" of the variable, it takes me to th I've created an extremely small XCode project that demonstrates the problem here Nothing more humbling than moving to a new language :) Thanks in advance.

    Read the article

  • C# - Why can't I enforce derived classes to have parameterless constructors?

    - by FrisbeeBen
    I am trying to do the following: public class foo<T> where T : bar, new { _t = new T(); private T _t; } public abstract class bar { public abstract void someMethod(); // Some implementation } public class baz : bar { public overide someMethod(){//Implementation} } And I am attempting to use it as follows: foo<baz> fooObject = new foo<baz>(); And I get an error explaining that 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. I fully understand why this must be, and also understand that I could pass a pre-initialized object of type 'T' in as a constructor argument to avoid having to 'new' it, but is there any way around this? any way to enforce classes that derive from 'bar' to supply parameterless constructors?

    Read the article

  • Domain-Driven-Design question

    - by Michael
    Hello everyone, I have a question about DDD. I'm building a application to learn DDD and I have a question about layering. I have an application that works like this: UI layer calls = Application Layer - Domain Layer - Database Here is a small example of how the code looks: //****************UI LAYER************************ //Uses Ioc to get the service from the factory. //This factory would be in the MyApp.Infrastructure.dll IImplementationFactory factory = new ImplementationFactory(); //Interface and implementation for Shopping Cart service would be in MyApp.ApplicationLayer.dll IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>(); //This is the UI layer, //Calling into Application Layer //to get the shopping cart for a user. //Interface for IShoppingCart would be in MyApp.ApplicationLayer.dll //and implementation for IShoppingCart would be in MyApp.Model. IShoppingCart shoppingCart = service.GetShoppingCartByUserName(userName); //Show shopping cart information. //For example, items bought, price, taxes..etc ... //Pressed Purchase button, so even for when //button is pressed. //Uses Ioc to get the service from the factory again. IImplementationFactory factory = new ImplementationFactory(); IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>(); service.Purchase(shoppingCart); //**********************Application Layer********************** public class ShoppingCartService : IShoppingCartService { public IShoppingCart GetShoppingCartByUserName(string userName) { //Uses Ioc to get the service from the factory. //This factory would be in the MyApp.Infrastructure.dll IImplementationFactory factory = new ImplementationFactory(); //Interface for repository would be in MyApp.Infrastructure.dll //but implementation would by in MyApp.Model.dll IShoppingCartRepository repository = factory.GetImplementationFactory<IShoppingCartRepository>(); IShoppingCart shoppingCart = repository.GetShoppingCartByUserName(username); //Do shopping cart logic like calculating taxes and stuff //I would put these in services but not sure? ... return shoppingCart; } public void Purchase(IShoppingCart shoppingCart) { //Do Purchase logic and calling out to repository ... } } I've seem to put most of my business rules in services rather than the models and I'm not sure if this is correct? Also, i'm not completely sure if I have the laying correct? Do I have the right pieces in the correct place? Also should my models leave my domain model? In general I'm I doing this correct according DDD? Thanks!

    Read the article

  • How to calculate median of a Map<Int,Int>?

    - by Chris
    For a map where the key represents a number of a sequence and the value the count how often this number appeared in the squence, how would an implementation of an algorithm in java look like to calculate the median? For example: 1,1,2,2,2,2,3,3,3,4,5,6,6,6,7,7 in a map: Map<Int,Int> map = ... map.put(1,2) map.put(2,4) map.put(3,3) map.put(4,1) map.put(5,1) map.put(6,3) map.put(7,2) double median = calculateMedian(map); print(median); would result in: > print(median); 3 > So what i am looking for is a java implementation of calculateMedian.

    Read the article

  • Unexpected result from reduce function

    - by StackedCrooked
    I would like to get the smallest element from a vector. For this I use combine the reduce and min functions. However, when providing my own implementation of min I get unexpected results: user=> (reduce (fn [x y] (< x y) x y) [1 2 3 2 1 0 1 2]) 2 user=> (reduce min [1 2 3 2 1 0 1 2 3]) 0 The reduce with standard min returns 0 as expected. However, when I provide my own implementation it returns 2. What am I doing wrong?

    Read the article

  • c++ property class structure

    - by Without me Its just Aweso
    I have a c++ project being developed in QT. The problem I'm running in to is I am wanting to have a single base class that all my property classes inherit from so that I can store them all together. Right now I have: class AbstractProperty { public: AbstractProperty(QString propertyName); virtual QString toString() const = 0; virtual QString getName() = 0; virtual void fromString(QString str) = 0; virtual int toInteger() = 0; virtual bool operator==(const AbstractProperty &rightHand) = 0; virtual bool operator!=(const AbstractProperty &rightHand) = 0; virtual bool operator<(const AbstractProperty &rightHand) = 0; virtual bool operator>(const AbstractProperty &rightHand) = 0; virtual bool operator>=(const AbstractProperty &rightHand) = 0; virtual bool operator<=(const AbstractProperty &rightHand) = 0; protected: QString name; }; then I am implementing classes such as PropertyFloat and PropertyString and providing implementation for the comparator operators based on the assumption that only strings are being compared with strings and so on. However the problem with this is there would be no compiletime error thrown if i did if(propertyfloat a < propertystring b) however my implementation of the operators for each derived class relies on them both being the same derived class. So my problem is I cant figure out how to implement a property structure so that I can have them all inherit from some base type but code like what I have above would throw a compile time error. Any ideas on how this can be done? For those familiar with QT I tried using also a implementation with QVariant however QVariant doesn't have operators < and defined in itself only in some of its derived classes so it didn't work out. What my end goal is, is to be able to generically refer to properties. I have an element class that holds a hashmap of properties with string 'name' as key and the AbstractProperty as value. I want to be able to generically operate on the properties. i.e. if I want to get the max and min values of a property given its string name I have methods that are completely generic that will pull out the associated AbstactProperty from each element and find the max/min no matter what the type is. so properties although initially declared as PropertyFloat/PropertyString they will be held generically.

    Read the article

  • What is the best way to expose a callback API - C++

    - by rursw1
    Hi, I have a C++ library that should expose some system\ resource calls as callbacks from the linked application. For example: the interfacing application (which uses this library) can send socket management callback functions - send, receive, open, close etc., and the library will use this implementation in stead of the library's implementation. (This way enables the application to manage the sockets by itself, can be useful). This library has to expose also more callbacks, like, for example, a password validation, so I wonder if there is a preferred method to expose the callback sending option in one API. Something like: int AddCallbackFunc (int functionCallbackType, <generic function prototype>, <generic way to pass some additional arguments>) Then within my library I will assign the callback to the appropriate function pointer according to the functionCallbackType parameter. Is there any way to implement it in a generic way which will fit ANY function prototype and ANY additional arguments? Your help will be more than appreciated... Thanks!

    Read the article

  • How to remove thie ".svc" extension in RESTful WCF service?

    - by Morgan Cheng
    In my knowledge, the RESTful WCF still has ".svc" in its URL. For example, if the service interface is like [OperationContract] [WebGet(UriTemplate = "/Value/{value}")] string GetDataStr(string value); The access URI is like "http://machinename/Service.svc/Value/2". In my understanding, part of REST advantage is that it can hide the implementation details. A RESTful URI like "http://machinename/Service/value/2" can be implemented by any RESTful framework, but a "http://machinename/Service.svc/value/2" exposes its implementation is WCF. How can I remove this ".svc" host in the access URI?

    Read the article

  • Change highlighting of certain subviews in a UITableViewCell

    - by SpacyRicochet
    Is it possible to exclude certain subviews in a UITableViewCell from being highlighted or to change their highlight implementation? I added an orange warning label to the UITableViewCell for certain occassions and it highlights properly with the rest of the cell, which is good. However, when the cells stops being highlighted in an animated way, you first see the background of the warning label become white and then flash to orange. I would either like it to be excluded from being highlighted at all, or to change it's highlight implementation so it animates back to orange properly.

    Read the article

  • Why this friend function can't access a private member of the class?

    - by Alceu Costa
    I am getting the following error when I try to access bins private member of the GHistogram class from within the extractHistogram() implementation: error: 'QVector<double> MyNamespace::GHistogram::bins' is private error: within this context Where the 'within this context' error points to the extractHistogram() implementation. Does anyone knows what's wrong with my friend function declaration? Here's the code: namespace MyNamespace{ class GHistogram { public: GHistogram(qint32 numberOfBins); qint32 getNumberOfBins(); /** * Returns the frequency of the value i. */ double getValueAt(qint32 i); friend GHistogram * Gbdi::extractHistogram(GImage *image, qint32 numberOfBins); private: QVector<double> bins; }; GHistogram * extractHistogram(GImage * image, qint32 numberOfBins); }

    Read the article

  • Are spinlocks a good choice for a memory allocator?

    - by dsimcha
    I've suggested to the maintainers of the D programming language runtime a few times that the memory allocator/garbage collector should use spinlocks instead of regular OS critical sections. This hasn't really caught on. Here are the reasons I think spinlocks would be better: At least in synthetic benchmarks that I did, it's several times faster than OS critical sections when there's contention for the memory allocator/GC lock. Edit: Empirically, using spinlocks didn't even have measurable overhead in a single-core environment, probably because locks need to be held for such a short period of time in a memory allocator. Memory allocations and similar operations usually take a small fraction of a timeslice, and even a small fraction of the time a context switch takes, making it silly to context switch in the case of contention. A garbage collection in the implementation in question stops the world anyhow. There won't be any spinning during a collection. Are there any good reasons not to use spinlocks in a memory allocator/garbage collector implementation?

    Read the article

  • The standard map/associative-array structure to use in flash actionscript 3?

    - by tstyle
    I'm relatively new to flash, and is confused about what I should use to store and retrieve key value pairs. After some googling I've found various map-like things to choose from: 1) Use a Object: var map:Object = new Object(); map["key"] = "value"; The problem is that it seems to lack some very basic features. For example to even get the size of map I'd have to write a util method. 2) Use a Dictionary What does this standard library class provide over the simple object? It seems silly for it to exist if it's functionally identical to Object. 3) Go download some custom HashMap/HashTable implementation from the web. I've used a lot of modern languages, and this is the first time I haven't been able to find a library implementation of an associative array within 5 minutes. So I'd like to get some best-practice advice from an experienced flash developer. Thanks!

    Read the article

  • Trouble with abstract generic methods

    - by DanM
    Let's say I have a class library that defines a couple entity interfaces: public interface ISomeEntity { /* ... */ } public interface ISomeOtherEntity { /* ... */ } This library also defines an IRepository interface: public interface IRepository<TEntity> { /* ... */ } And finally, the library has an abstract class called RepositorySourceBase (see below), which the main project needs to implement. The goal of this class is to allow the base class to grab new Repository objects at runtime. Because certain repositories are needed (in this example a repository for ISomeEntity and ISomeOtherEntity), I'm trying to write generic overloads of the GetNew<TEntity>() method. The following implementation doesn't compile (the second GetNew() method gets flagged as "already defined" even though the where clause is different), but it gets at what I'm trying to accomplish: public abstract class RepositorySourceBase // This doesn't work! { public abstract Repository<TEntity> GetNew<TEntity>() where TEntity : SomeEntity; public abstract Repository<TEntity> GetNew<TEntity>() where TEntity : SomeOtherEntity; } The intended usage of this class would be something like this: public class RepositorySourceTester { public RepositorySourceTester(RepositorySourceBase repositorySource) { var someRepository = repositorySource.GetNew<ISomeEntity>(); var someOtherRepository = repositorySource.GetNew<ISomeOtherEntity>(); } } Meanwhile, over in my main project (which references the library project), I have implementations of ISomeEntity and ISomeOtherEntity: public class SomeEntity : ISomeEntity { /* ... */ } public class SomeOtherEntity : ISomeOtherEntity { /* ... */ } The main project also has an implementation for IRepository<TEntity>: public class Repository<TEntity> : IRepository<TEntity> { public Repository(string message) { } } And most importantly, it has an implementation of the abstract RepositorySourceBase: public class RepositorySource : RepositorySourceBase { public override Repository<SomeEntity> GetNew() { return new Repository<SomeEntity>("stuff only I know"); } public override Repository<SomeOtherEntity> GetNew() { return new Repository<SomeOtherEntity>("other stuff only I know"); } } Just as with RepositorySourceBase, the second GetNew() method gets flagged as "already defined". So, C# basically think I'm repeating the same method because there's no way to distinguish the methods from parameters, but if you look at my usage example, it seems like I should be able to distinguish which GetNew() I want from the generic type parameter, e.g, <ISomeEntity> or <ISomeOtherEntity>. What do I need to do to get this to work?

    Read the article

< Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >