Search Results

Search found 40730 results on 1630 pages for 'type erasure'.

Page 47/1630 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • Explain Type Classes in Haskell

    - by Tsubasa Gomamoto
    Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?

    Read the article

  • MySql TABLE data type

    - by Neil Aitken
    MS SQL Server has a TABLE data type which can be used in stored procedures, Does anybody know if MySQL has an equivalent data type? I've had a look over the docs but can't seem to find anything, so I presume it doesn't exist, but perhaps somebody has created a workaround

    Read the article

  • How to define type member constant in F# ?

    - by zproxy
    In C# one can define a type member constant like this: class Foo { public const int Bar = 600; } The IL shall looks like this. .field public static literal int32 Bar = int32(600) How can I do the same within Visual F# / FSharp? I tried this to no avail: [<Sealed>] type Foo() = [<Literal>] let Bar = 600

    Read the article

  • A simple question about type coercion in C++

    - by David
    Given a function prototype, and a type definition: int my_function(unsigned short x); typedef unsigned short blatherskite; Is the following situation defined by standard: int main(int argc, char** argv) { int result; blatherskite b; b=3; result = my_function(b); } Do I get type coercion predictably via the function prototype?

    Read the article

  • C++: get const or non-const reference type from trait

    - by maciekp
    I am writing a functor F which takes function of type void (*func)(T) and func's argument arg. Then functor F calls func with arg. I would like F not to copy arg, just to pass it as reference. But then I cannot simply write "void F(void (*func)(T), T&)" because T could be a reference. So I am trying to write a trait, which allows to get proper reference type of T: T -> T& T& -> T& const T -> const T& const T& -> const T& I come up with something like this: template<typename T> struct type_op { typedef T& valid_ref_type; }; template<typename T> struct type_op<T&> { typedef typename type_op<T>::valid_ref_type valid_ref_type; }; template<typename T> struct type_op<const T> { typedef const T& valid_ref_type; }; template<typename T> struct type_op<const T&> { typedef const T& valid_ref_type; }; Which doesn't work for example for void a(int x) { std::cout << x << std::endl; } F(&a, 7); Giving error: invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int’ in passing argument 2 of ‘void f(void (*)(T), typename type_op::valid_ref_type) [with T = int]’ How to get this trait to work?

    Read the article

  • java mapping for oracle number type

    - by aauser
    I have database with oracle number type. Could there any possible issues with using java Double when updating table with numeric column. Should i switch BigDecimal or Double is approriate type. As I fas as I know, BigDecimal is used when arbitrary precision required, when deal with prices for example. Consider simple API updatePrice(Double d) Should i persist double as is or BigDecimal.valueOf(d) is preferable ?

    Read the article

  • Interop type cannot be embedded

    - by Jan
    I am creating an web application on the .net 4.0 framework (beta2 ) in C#. When I try to use a assembly called "ActiveHomeScriptLib", I get the following error: Interop type 'ActiveHomeScriptLib.ActiveHomeClass' cannot be embedded. Use the applicable interface instead. When I change the framework to version 3.5, I don't have any errors. What is an Interop Type and why does this only occur when I use the 4.0 framework.

    Read the article

  • C# Type Casting at Runtimefor Array.SetValue

    - by sprocketonline
    I'm trying to create an array using reflection, and insert values into it. I'm trying to do this for many different types so would like a createAndFillArray function capable of this : Type t1 = typeof(A); Type t2 = typeof(B); double exampleA = 22.5; int exampleB = 43; Array arrA = createAndFillArray(t1, exampleA); Array arrB = createAndFillArray(t2, exampleB); private Array createAndFillArray(Type t, object val){ Array arr = Array.CreateInstance( t, 1); //length 1 in this example only, real-world is of variable length. arr.SetValue( val, 0 ); //this causes the following error: "System.InvalidCastException : Object cannot be stored in an array of this type." return arr; } with the class A being as follows: public class A{ public A(){} private double val; public double Value{ get{ return val; } set{ this.val = value; } } public static implicit operator A(double d){ A a = new A(); a.Value = d; return a; } } and class B being very similar, but with int: public class B{ public B(){} private double val; public double Value{ get{ return val; } set{ this.val = value; } } public static implicit operator B(double d){ B b = new B(); b.Value = d; return b; } } I hoped that the implicit operator would have ensured that the double be converted to class A, or the int to class B, and the error avoided; but this is obviously not so. The above is used in a custom deserialization class, which takes data from a custom data format and fills in the corresponding .Net object properties. I'm doing this via reflection and at runtime, so I think both are unavoidable. I'm targeting the C# 2.0 framework. I've dozens, if not hundreds, of classes similar to A and B, so would prefer to find a solution which improved on the createAndFillArray method rather than a solution which altered these classes.

    Read the article

  • How to convert a PGresult to custom data type with libpq (PostgreSQL)

    - by mocopera
    Hi everyone! I'm using the libpq library in C to accessing my PostgreSQL database. So, when I do res = PQexec(conn, "SELECT point FROM test_point3d"); I don't know how to convert the PGresult I got to my custom data type. I know I can use the PQgetValue function, but again I don't know how to convert the returning string to my custom data type. Any suggestion? Thanks in advice.

    Read the article

  • Nullable type conversion in C#?

    - by dinesh
    Hi can we assign null value to struct type of variable? struct MyStruct { } MyStruct var = null; is this is possible in C# .net? if not ? then how C# is allowing Nullable < T struct type of variable can be assigned as null?

    Read the article

  • F# compilation error: Unexpected type application

    - by Jim Burger
    In F#, given the following class: type Foo() = member this.Bar<'t> (arg0:string) = ignore() Why does the following compile: let f = new Foo() f.Bar<Int32> "string" While the following won't compile: let f = new Foo() "string" |> f.Bar<Int32> //The compiler returns the error: "Unexpected type application"

    Read the article

  • Hook perm for more than one content type

    - by Andrew
    Drupal 6.x I have this module that manages four different content types. For that matter, how do I define permission for each content within the same module? Is that even possible? I can't figure out how to define permission for each content type cuz hook_perm has to be named with module name and it doesn't have any argument(like hook_access $node) to return permission base on content type. Any help would be highly appreciated.

    Read the article

  • converting an interface to a type in MVC

    - by danielovich
    Hi. I have a small isuse regarding an interface. Consider this code: [HttpPost()] public void Update(IAuctionItem item) { RedirectToAction("List"); } Whenever I call this I get an exception saying I can't create an instance of type which i totally correct. But is there a way of telling what the interface should map to without actually using the concrete type ?

    Read the article

  • Get drive type with SetupDiGetDeviceRegistryProperty

    - by new
    Dear all, I would like to know whether i can get the drive information using the SP_DEVICE_INTERFACE_DETAIL_DATA's DevicePath my device path looks like below "\?\usb#vid_04f2&pid_0111#5&39fe81e&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}" also please tell me in the winapi they say "To determine whether a drive is a USB-type drive, call SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY property." i too use SetupDiGetDeviceRegistryProperty like below while ( !SetupDiGetDeviceRegistryProperty( hDevInfo,&DeviceInfoData, SPDRP_REMOVAL_POLICY,&DataT,( PBYTE )buffer,buffersize,&buffersize )) but i dont know how can i get the drive type using the above.. Please help me up

    Read the article

  • Get derived class type from a base's class static method

    - by Marco Bettiolo
    Hi, i would like to get the type of the derived class from a static method of its base class. How can this be accomplished? Thanks! class BaseClass { static void Ping () { Type t = this.GetType(); // should be DerivedClass, but it is not possible with a static method } } class DerivedClass : BaseClass {} // somewhere in the code DerivedClass.Ping();

    Read the article

  • Reflection problem - Type Safety Warning

    - by jax
    Class<? extends Algorithm> alg = AlgorithmAllFrom9AndLastFrom10Impl.class Constructor<Algorithm> c = alg.getConstructors()[0]; For "alg.getConstructors()[0];" I am getting a warning in eclipse Type safety: The expression of type Constructor needs unchecked conversion to conform to Constructor How do I fix this?

    Read the article

  • Parsing values from XML into types of Type

    - by DrLazer
    check this out Type configPropType = configurableProp.getPropertyType(); string attValue = xmlelement.GetAttribute(configurableProp.getName()); configProps[configurableProp.getName()] = attValue; At the point where I am setting the value that got read in from XML it turns out the assigning object needs to be parsed to the correct type for it to work. I need something like. configProps[configurableProp.getName()] = configPropType.ParseToThisType(attValue); Looked around on msdn but its a very confusing place.

    Read the article

  • C++ dynamic type construction and detection

    - by KneLL
    There was an interesting problem in C++, but it concerns more likely architecture. There are many (10, 20, 40, etc) classes that describe some characteristics (mix-in classes), for exmaple: struct Base { virtual ~Base() {} }; struct A : virtual public Base { int size; }; struct B : virtual public Base { float x, y; }; struct C : virtual public Base { bool some_bool_state; }; struct D : virtual public Base { string str; } // .... Primary module declares and exports a function (for simplicity just function declarations without classes): // .h file void operate(Base *pBase); // .cpp file void operate(Base *pBase) { // .... } Any other module can has a code like this: #include "mixins.h" #include "primary.h" class obj1_t : public A, public C, public D {}; class obj2_t : public B, public D {}; // ... void Pass() { obj1_t obj1; obj2_t obj2; operate(&obj1); operate(&obj2); } The question is how to know what the real type of given object in operate() without dynamic_cast and any type information in classes (constants, etc)? Function operate() is used with big array of objects in small time periods and dynamic_cast is too slow for it. And I don't want to include constants (enum obj_type { ... }) because this is not OOP-way. // module operate.cpp void some_operate(Base *pBase) { processA(pBase); processB(pBase); } void processA(A *pA) { } void processB(B *pB) { } I cannot directly pass a pBase to these functions. And it's impossible to have all possible combinations of classes, because I can add new classes just by including new .h files. As one of solutions that comed to mind, in editor application I can use a composite container: struct CompositeObject { vector<Base *pBase> parts; }; But editor does not need a time optimization and can use dynamic_cast for parts to determine the exact type. In operate() I cannot use this solution. So, is it possible to not use a dynamic_cast and type information to solve this problem? Or maybe I should use another architecture?

    Read the article

  • SQL Server Text type v.s. varchar data type

    - by George2
    Hello everyone, I have variable length character and want to store in SQL Server (2005) database. I want to learn some best practices about how to choose TEXT SQL type or choose VARCHAR SQL type, pros and cons in performance/footprint/function. thanks in advance, George

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >