Search Results

Search found 5101 results on 205 pages for 'expression trees'.

Page 152/205 | < Previous Page | 148 149 150 151 152 153 154 155 156 157 158 159  | Next Page >

  • C++0x rvalue references - lvalues-rvalue binding

    - by Doug
    This is a follow-on question to http://stackoverflow.com/questions/2748866/c0x-rvalue-references-and-temporaries In the previous question, I asked how this code should work: void f(const std::string &); //less efficient void f(std::string &&); //more efficient void g(const char * arg) { f(arg); } It seems that the move overload should probably be called because of the implicit temporary, and this happens in GCC but not MSVC (or the EDG front-end used in MSVC's Intellisense). What about this code? void f(std::string &&); //NB: No const string & overload supplied void g1(const char * arg) { f(arg); } void g2(const std::string & arg) { f(arg); } It seems that, based on the answers to my previous question that function g1 is legal (and is accepted by GCC 4.3-4.5, but not by MSVC). However, GCC and MSVC both reject g2 because of clause 13.3.3.1.4/3, which prohibits lvalues from binding to rvalue ref arguments. I understand the rationale behind this - it is explained in N2831 "Fixing a safety problem with rvalue references". I also think that GCC is probably implementing this clause as intended by the authors of that paper, because the original patch to GCC was written by one of the authors (Doug Gregor). However, I don't this is quite intuitive. To me, (a) a const string & is conceptually closer to a string && than a const char *, and (b) the compiler could create a temporary string in g2, as if it were written like this: void g2(const std::string & arg) { f(std::string(arg)); } Indeed, sometimes the copy constructor is considered to be an implicit conversion operator. Syntactically, this is suggested by the form of a copy constructor, and the standard even mentions this specifically in clause 13.3.3.1.2/4, where the copy constructor for derived-base conversions is given a higher conversion rank than other implicit conversions: A conversion of an expression of class type to the same class type is given Exact Match rank, and a conversion of an expression of class type to a base class of that type is given Conversion rank, in spite of the fact that a copy/move constructor (i.e., a user-defined conversion function) is called for those cases. (I assume this is used when passing a derived class to a function like void h(Base), which takes a base class by value.) Motivation My motivation for asking this is something like the question asked in http://stackoverflow.com/questions/2696156/how-to-reduce-redundant-code-when-adding-new-c0x-rvalue-reference-operator-over ("How to reduce redundant code when adding new c++0x rvalue reference operator overloads"). If you have a function that accepts a number of potentially-moveable arguments, and would move them if it can (e.g. a factory function/constructor: Object create_object(string, vector<string>, string) or the like), and want to move or copy each argument as appropriate, you quickly start writing a lot of code. If the argument types are movable, then one could just write one version that accepts the arguments by value, as above. But if the arguments are (legacy) non-movable-but-swappable classes a la C++03, and you can't change them, then writing rvalue reference overloads is more efficient. So if lvalues did bind to rvalues via an implicit copy, then you could write just one overload like create_object(legacy_string &&, legacy_vector<legacy_string> &&, legacy_string &&) and it would more or less work like providing all the combinations of rvalue/lvalue reference overloads - actual arguments that were lvalues would get copied and then bound to the arguments, actual arguments that were rvalues would get directly bound. Questions My questions are then: Is this a valid interpretation of the standard? It seems that it's not the conventional or intended one, at any rate. Does it make intuitive sense? Is there a problem with this idea that I"m not seeing? It seems like you could get copies being quietly created when that's not exactly expected, but that's the status quo in places in C++03 anyway. Also, it would make some overloads viable when they're currently not, but I don't see it being a problem in practice. Is this a significant enough improvement that it would be worth making e.g. an experimental patch for GCC?

    Read the article

  • How can I force input to uppercase in an asp.net textbox?

    - by Aheho
    I'm writing an asp.net application. I have a textbox on a webform and I want to force whatever the user types to upper case. I'd like to do this on the front end. You should also note that there is a validation control on this textbox, so I want to make sure the solution doesn't interfere with the asp.net validation. Clarification: It appears that the CSS text-tranform makes the user input appear in uppercase, however under the hood, it's still lower case as the validation control fails. You see, my validation control checks to see if a valid state code is entered, however the regex expression I"m using only works with uppercase characters.

    Read the article

  • C# Finisar SQLite Date Format Problem

    - by Emanuel
    My "task" database table look like this: [title] [content] [start_date] [end_date] [...] [...] [01.06.2010 20:10:36] [06.06.2010 20:10:36] [...] [...] [05.06.2010 20:10:36] [06.06.2010 20:10:36] And I want to find only those records that meet the condition that a given day is between start_date and end_date. I've tried the following SQL expression: SELECT * FROM task WHERE strftime ('%d', 'start_date') <= @day AND @day <= strftime ('%d', 'end_date') Where @day is an SQLiteParameter (eq 5). But no result is returned. How can I solve this problem? Thanks.

    Read the article

  • C2664 when casting child class to templated parent class

    - by DC
    I have a parent class which is templated, and a child class which implements it. template< typename T1, typename T2> class ParentClass{ . . . }; class ChildClass : public ParentClass<MyT1, MyT2> { . . . }; And I want to have a pointer which I can use polymorphically: ParentClass<T1, T2>* ptr; ptr = static_cast<ParentClass<MyT1, MyT2>* >(new ChildClass() ); No matter how I cast it, I always get a C2664 which has the same expression: error C2664: cannot convert parameter 1 from 'ParentClass< T1,T2 *' to 'ParentClass< T1,T2 *' Is it not possible to cast pointer types between inherited types if the parent is templated, even if the types specified in the templates are the same?

    Read the article

  • WPF with code only

    - by rwallace
    I've seen a lot of questions about the merits of WPF here, and essentially every answer says it's the bee's knees, but essentially every answer also talks about things like XAML, in many cases graphic designers and Expression Blend etc. My question is, is it worth getting into WPF if you're a solo coder working in C# only? Specifically, I don't have a graphic designer, nor any great talent in that area myself; I don't use point-and-click tools; I write everything in C#, not XML. Winforms works fine in those conditions. Is the same true of WPF, or does it turn out that important functions can only be done in XAML, the default settings aren't intended for actual use and you have to have a graphic designer on the team to make things look good, etc., and somebody in my position would be better off to stick to Winforms?

    Read the article

  • Using DataTypeAttribute to validate a date

    - by Andy Evans
    I'm having some difficulty understanding how to validate a date (DOB) using MVC2. What I want to do is 1. Is the date entered a valid date and, 2. Is the date at lease 13 years in the past. For example, to validate an email I use the following code: [Required(ErrorMessage = "Email address is required.")] [StringLength(320, ErrorMessage = "Email must be less than 320 characters.")] [Email(ErrorMessage = "This email address is invalid.")] public string email { get; set; } To validate the email I use: public class EmailAttribute : RegularExpressionAttribute { public EmailAttribute() : base("insert long regex expression here") { } } Any assistance would be greatly appreciated, thanks!

    Read the article

  • Call function in query in Entity framework 3.5

    - by Ashwani K
    Hello All: I am trying to run following query in entity framework 3.5 var test = from e in customers where IsValid(e) select e; Here IsValid function takes current customer and validate against some conditions and returns false or true. But when I am trying to run the query it is giving error "LINQ Method cannot be translated into a store expression." Can any body tell me any other approach? One approach I can think of is to write all validation conditions here, but that will make the code difficult to read. Thanks Ashwani

    Read the article

  • NAnt IF task doesn't seem to work

    - by goombaloon
    I'm trying the example from the NAnt documentation for the if task at: http://nant.sourceforge.net/release/0.85/help/tasks/if.html Specifically the following code... <if test="${build.configuration='release'}"> <echo>Build release configuration</echo> </if> where build.configuration has been defined beforehand as <property name="build.configuration" value="debug" overwrite="false" /> When I run it using nant.exe (version 0.91.3881.0), I get the following error: '}' expected Expression: ${build.configuration='release'} ^ I'm guessing I'm missing something simple?

    Read the article

  • data type mismatch when comparing dates in MS-Access

    - by jonos
    I have dates stored in an MS-Access table in the 'General Date' format. I'm trying to create a query that returns records between a specific date range (all records from March 2010) however I encounter a 'data type mismatch in critera expression' message. Here is my statement; SELECT Loan.loan_datetimeLeant, product_name, [product_artist/director], product_category, loanItem_cost FROM Loan INNER JOIN ((Product INNER JOIN Item ON Product.[product_id] = Item.[product_id]) INNER JOIN Loan_Items ON Item.[item_id] = Loan_Items.[item_id]) ON (Loan.[cust_id] = Loan_Items.[cust_id]) AND (Loan.[loan_datetimeLeant] = Loan_Items.[loan_datetimeLeant]) WHERE Loan.loan_datetimeLeant = '01/03/2010' AND Loan.loan_datetimeLeant <= '31/03/2010' ORDER BY Loan.loan_datetimeLeant ; I have tried variations on the date format (mm/dd/yyyy, dd/mm/yyyy 00:00:00)

    Read the article

  • Regexp to add attribute in any xml tags

    - by katsuo11
    Hello, I have well-formed xml documents into string variables. I want to use preg_replace to add a defined attribute to every xml tags. For example replace: <tag1> <tag2> some text </tag2> </tag1> by: <tag1 attr="myAttr"> <tag2 attr="myAttr"> some text </tag2> </tag1> So I basically need the regex expression to find any start tags and add my attribute, but I'm a complete regex noob. Thanks, kats

    Read the article

  • Regular expressions and matching URLs with metacharacters

    - by James P.
    I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \? as a valid escape sequence but it also fails to work with the tester at myregexp.com. Here's what I have so far: ([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+ Any suggestions? Edit: The original intent was to match all URLs that could be found after the first semi colon.

    Read the article

  • PostgreSQL like + Hibernate problem

    - by Marat_Galiev
    Hi all. I want to do search in PostgreSQL for INTEGER based columns. if (!sSearch.isEmpty()) { sSearch = sSearch.replaceAll("[^a-zA-Z0-9]", "_").toLowerCase(); String[] search = sSearch.split(" "); sWhere = " "; for (NewsColumns column : NewsColumns.values()) { for (String s : search) { sWhere += "lower(" + column + "::TEXT) LIKE '%" + s + "%' OR "; } } sWhere = sWhere.substring(0,sWhere.length()-3); } Ok, I want to convert INT value to String before search, with '::TEXT' expression. But after executing I'm getting: org.hibernate.QueryException: Not all named parameters have been set: [:TEXT] [select * from news WHERE lower(ID::TEXT) LIKE '%5%' Exception. Looks like hibernate parse my convert exp as parameter. Any help is appreciated. Thanks.

    Read the article

  • Retrieve baseUri w/o resorting to Application.Current

    - by beaudetious
    My custom controls are not loading in VS.NET's designer because of a null reference exception. It's got everything to do with the way I am retrieving the baseUri of the application when it runs in the browser: _uriPrefix = Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf("/ClientBin")).Trim(); According to the exception details and the help file I'm directed to (here) I'm not correctly designing my app for a runtime that's not the browser (i.e. the new WPF editor in VS.NET or Expression Blend). So, the question is how do retrieve the baseUri (the http://localhost:#### part of my application) if I can't use Application.Host which apparently is null during design time? is there a safe way to do this so I can load my custom controls in a designer?

    Read the article

  • php regex replace slashes and spaces and hyphens

    - by Muhammad Shahzad
    I have fews combinations of strings that I need to bring in to one pattern, that is multiple spaces should be removed, double hyphens should be replaced with single hypen, and single space should be replaced with single hyphen. I have already tried this expression. $output = preg_replace( "/[^[:space:]a-z0-9]/e", "", $output ); $output = trim( $output ); $output = preg_replace( '/\s+/', '-', $output ); But this fails in few combinations. I need help in making all of these combinations to work perfectly: steel-black steel- black steel black I should also remove any of these as well "\r\n\t".

    Read the article

  • Determine if a string contains only alphanumeric characters (or a space)

    - by dreamlax
    I'm learning C++ and I am writing a function that determines whether a string contains only alphanumeric characters and spaces. I suppose I am effectively testing whether it matches the regular expression ^[[:alnum:] ]+$ but without using regular expressions. I have seen a lot of algorithms revolve around iterators, so I tried to find a solution that made use of iterators, and this is what I have: #include <algorithm> static inline bool is_not_alnum_space(char c) { return !(isalpha(c) || isdigit(c) || (c == ' ')); } bool string_is_valid(const std::string &str) { return find_if(str.begin(), str.end(), is_not_alnum_space) == str.end(); } Is there a better solution, or a “more C++” way to do this?

    Read the article

  • How to check html tag with Rspec

    - by Tetsu
    I'm learning from this site. I tested the following with rspec, and it passed. describe "About page" do it "should have the content 'About Us'" do visit '/static_pages/about' expect(page).to have_content('About Us') end end I changed About Us to <h1>About Us</h1> to check whether it works as I expected, but the test fails even when about.html.erb has the string <h1>About Us</h1>. Could you show me how I can use html tag expression in rspec file?

    Read the article

  • Regex for finding valid sphinx fields

    - by mlissner
    I'm trying to validate that the fields given to sphinx are valid, but I'm having difficulty. Imagine that valid fields are cat, mouse, dog, puppy. Valid searches would then be: @cat search terms @(cat) search terms @(cat, dog) search term @cat searchterm1 @dog searchterm2 @(cat, dog) searchterm1 @mouse searchterm2 So, I want to use a regular expression to find terms such as cat, dog, mouse in the above examples, and check them against a list of valid terms. Thus, a query such as: @(goat) Would produce an error because goat is not a valid term. I've gotten so that I can find simple queries such as @cat with this regex: (?:@)([^( ]*) But I can't figure out how to find the rest. I'm using python & django, for what that's worth.

    Read the article

  • Regex for Searching for Text Not Preceeded By a Specific String

    - by James
    Hi, I am working on a web site with several other developers and we have had problems where people commit JavaScript code with AJAX calls that use URL's relative to the site root. An example would be /Home/Index which will not work if the site is hosted in a virtual directory. To get round the problem we use a $.url() method to convert it to a full path, e.g. $("#container").load($.url("/Home/Index")) I am trying to write a unit test that will search each JavaScript file and find places where the $.url method is not being used. The only problem is that I cannot seem to write a regex expression to do this. I have tried the following: (?!\$\.url\()"(/\w*)+" But this does not work. I cannot find a way to say that I don't want the $.url in front. Does anyone know if this is possible? Note that I need regular expressions that are compatible with .NET Thanks.

    Read the article

  • regex for matching strings that have illegal filename characters.

    - by cchampion
    I been trying to figure out how this blasted regex for two hours!!! It's midnight I gotta figure this out and go to bed!!! String str = new String("filename\\"); if(str.matches(".*[?/<>|*:\"{\\}].*")) { System.out.println("match"); }else { System.out.println("no match"); } ".*[?/<>|*:\"{\\}].*" is my regex expression. It catches everything correctly except the backslash!!! I need to know how to make it catch the backslash correctly please help! FYI, the illegal characters i'm trying to catch are ? \ / < | * : " I've got it working exception for the backslash

    Read the article

  • Conditionally set a column to its default value in Postgres

    - by Evgeny
    I've got a PostgreSQL 8.4 table with an auto-incrementing, but nullable, integer column. I want to update some column values and, if this column is NULL then set it to its default value (which would be an integer auto-generated from a sequence), but I want to return its value in either case. So I want something like this: UPDATE mytable SET incident_id = COALESCE(incident_id, DEFAULT), other = 'somethingelse' WHERE ... RETURNING incident_id Unfortunately, this doesn't work - it seems that DEFAULT is special and cannot be part of an expression. What's the best way to do this?

    Read the article

  • .NET: Best way to execute a lambda on UI thread after a delay?

    - by Scott Bussinger
    I had a situation come up that required running a lambda expression on the UI thread after a delay. I thought of several ways to do this and finally settled on this approach Task.Factory.StartNew(() => Thread.Sleep(1000)) .ContinueWith((t) => textBlock.Text="Done",TaskScheduler.FromCurrentSynchronizationContext()); But I'm wondering if there's an easier way that I missed. Any suggestions for a shorter, simpler or easier technique? Assume .NET 4 is available.

    Read the article

  • Passing functions as arguements in Matlab

    - by Dave
    Hi, I'm trying to write a function that is gets two arrays and the name of another function as arguements. e.g. main.m: x=[0 0.2 0.4 0.6 0.8 1.0]; y=[0 0.2 0.4 0.6 0.8 1.0]; func2(x,y,'func2eq') func 2.m : function t =func2(x, y, z, 'func') //"unexpected matlab expression" error message here t= func(x,y,z); func2eq.m: function z= func2eq(x,y) z= x + sin(pi * x)* exp(y); Matlab tells gives me the above error message. I've never passed a function name as an arguement before. Where am I going wrong? p.s. sorry about the formatting of code above, I can't seems to get SO to show parts of the code as code.

    Read the article

  • VB to C# conversion incongruency with lambdas

    - by Jason
    I have a bit of code that I have been tasked with converting to C# from VB. A snippet of mine seems like it cannot be converted from one to the other, and if so, I just don't know how to do it and am getting a little frustrated. Here's some background: OrderForm is an abstract class, inherited by Invoice (and also PurchaseOrder). The following VB snippet works correctly: Dim Invs As List(Of OrderForm) = GetForms(theOrder.OrderID) .... Dim inv As Invoice = Invs.Find( Function(someInv As Invoice) thePO.SubPONumber = someInv.SubInvoiceNumber) In C#, the best I came to converting this is: List<OrderForm> Invs = GetForms(theOrder.OrderID); .... Invoice inv = Invs.Find( (Invoice someInv) => thePO.SubPONumber == someInv.SubInvoiceNumber); However, I get the following error when I do this: Cannot convert lambda expression to delegate type 'System.Predicate' because the parameter types do not match the delegate parameter types Is there any way to fix this without restructuring my whole codebase?

    Read the article

  • Convert inline image tags like [image:123:title:size] into HTML img tags

    - by Jacques Joubert
    I am looking for help with regular expression $pattern to convert inline image tags like [image:123:title:size] into HTML img tags. here is the code: //[image:ID:caption:size] $content = '[image:38:title:800x900]'; preg_match_all( '/\[image:(\d+)(:?)([^\]]*)\]/i', $content, $images ); if( !empty( $images[0] ) ) { // There are image inline tags in the content foreach( $images[0] as $i => $tag ) { $link_ID = (int)$images[1][$i]; $caption = empty( $images[2][$i] ) ? '#' : $images[3][$i]; $size = empty( $images[4][$i] ) ? '#' : $images[4][$i]; } echo '<br />'; echo 'ID: '.$link_ID.'<br />'; echo 'Tag: '.$caption.'<br />'; echo 'size: '.$size.'<br />'; } which outputs: ID: 12 Tag: caption:size size: # Any help would be great!

    Read the article

  • How do I use global resources in WPF?

    - by Banford
    I have a WPF application which I would like to use some static resources in. I have created a Resource Library XAML file which contains a resource. I have also added a string into the Resources of the project through the Properties panel. I assumed I could just use these resources with the binding expression: {StaticResource ResourceName} But visual studio is telling me the resources are not found. Do I have to include some form of reference in my XAML? The examples I have seen only include resources locally such as: <Window.Resources>, <Page.Resources> etc I don't want to include the resources locally because I want them to be available to multiple parts of the application.

    Read the article

< Previous Page | 148 149 150 151 152 153 154 155 156 157 158 159  | Next Page >